Сабж. Код activity:
package com.gobonus.gobonus;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class InternetDisabled extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_internet_disabled);
AlertDialog.Builder builder =
new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle(R.string.title);
builder.setMessage(R.string.err_503);
builder.setNegativeButton("Exit", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
});
builder.show();
}
}
Манифест:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gobonus.gobonus">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/welcomeActivivty">
<activity android:name=".WelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login"
android:theme="@style/GB"
android:parentActivityName=".WelcomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.gobonus.gobonus.WelcomeActivity" />
</activity>
<activity android:name=".InternetDisabled"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"/>
<activity
android:name=".CabinetActivity"
android:label="@string/title_activity_cabinet"
android:theme="@style/GB_Green.NoActionBar" />
<activity
android:name=".CabinetActivityy"
android:label="@string/title_activity_cabinet_activityy"
android:theme="@style/GB_Green.NoActionBar"></activity>
</application>
</manifest>
Стиль (без указания версии api, лежит в /values/styles.xml):
<!--alert dialog-->
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#FFCC00</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:background">#5fa3d0</item>
</style>
В логах никаких ошибок нет.
На API 18 (4.3) я получаю вот такое некрасивое окошко:
На API 22 все нормально:
Почему так? И как это решить? Тестил только на API 18 и 22
Разметка:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.gobonus.gobonus.InternetDisabled">
</RelativeLayout>