您好我正在尝试将一个主题应用于我的应用中弹出的所有AlertDialogs并创建了必要的
<style name="Theme.jon" parent="@style/Theme.AppCompat.Light.DarkActionBar"> theme in my styles.xml file below:
<item name="android:alertDialogTheme">@style/jon.dialog</item>
</style>
<style name="jon.dialog" parent="@android:style/Theme.Holo.Dialog">
<item name="android:maxLines">1</item>
<item name="android:paddingTop">21dp</item>
<item name="android:paddingBottom">16dp</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
<item name="android:scrollHorizontally">true</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:background">@drawable/rounded_corners</item>
<item name="android:textColor">@color/text_color_grey</item>
<item name="android:windowNoTitle">false</item>
<item name="android:buttonBarStyle">@style/jon.ButtonBar.AlertDialog</item>
</style>
<style name="jon.ButtonBar.AlertDialog" parent="@android:style/Holo.ButtonBar.AlertDialog">
<item name="android:background">@drawable/bg_searching_bottom</item>
<item name="android:layout_height">@dimen/margin_40dp</item>
<item name="android:textColor">@color/text_color_grey</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_width">match_parent</item>
</style>
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jon.jon">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:name=".LibraryApplication"
android:label="@string/app_name"
android:theme="@style/Theme.jon">
<service
android:name=".net.networklib.NetworkService"
android:exported="true"/>
</application>
这是我典型的如何显示对话框
/**
* Construct error message dialog
*
* @param context
* @param title
* @param message
* @return
*/
private static AlertDialog getErrorDialog(Context context, String title, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setNeutralButton(android.R.string.ok, null);
builder.setTitle(title);
builder.setMessage(message);
return builder.show();
}
不确定缺少什么,但我的对话框没有改变其外观
答案 0 :(得分:4)
在Theme.jon
的声明中,替换
<item name="android:alertDialogTheme">@style/jon.dialog</item>
与
<item name="alertDialogTheme">@style/jon.dialog</item>
答案 1 :(得分:3)
替换下面的行
<style name="Theme.jon" parent="@style/Theme.AppCompat.Light.DarkActionBar">
与
<style name="Theme.jon" parent="Theme.AppCompat.Light.DarkActionBar">
多数民众赞成......