我已经为此感到头疼了。我需要做的是,更改AlertDialog
我的 android 应用程序中所有 s 的样式 - 对话框背景需要是白色的,文本需要是黑色的。我尝试从代码、清单等创建很多样式、主题和应用,但没有成功,关于AlertDialog
. 现在,我有最简单的代码,设置如下:
显现:
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" >
样式.xml:
<style name="AppTheme" parent="AppBaseTheme"> <item name="android:alertDialogStyle">@style/DialogStyle</item> </style> <style name="DialogStyle" parent="@android:style/Theme.Dialog"> <!-- changing these background stuff works fine --> <item name="android:bottomBright">@android:color/white</item> <item name="android:bottomDark">@android:color/white</item> <item name="android:bottomMedium">@drawable/dialog_footer_bg</item> <item name="android:centerBright">@android:color/white</item> <item name="android:centerDark">@drawable/dialog_body_bg</item> <item name="android:centerMedium">@android:color/white</item> <item name="android:fullBright">@color/orange</item> <item name="android:fullDark">@color/orange</item> <item name="android:topBright">@color/green</item> <item name="android:topDark">@drawable/dialog_header_bg</item>
下面列出的项目不起作用(请阅读我在每个元素上方的评论):
<!-- panelBackground is not getting set to null, there is something squarish around it --> <item name="android:panelBackground">@null</item> <!-- Setting this textColor doesn't seem to have any effect at all. Messages, title, button text color, whatever; nothing changes. --> <item name="android:textColor">#000000</item> <!-- Also tried with textAppearance, as follows. Didn't work --> <item name="android:textAppearance">?android:attr/textColorPrimaryInverse</item> <!-- Also tried changing textAppearancePrimary, to no avail --> <item name="android:textColorPrimary">#000000</item> <!-- Also need to change the dialog title text, tried it as follows, dint work: --> <item name="android:windowTitleStyle">@style/DialogWindowTitle</item> </style>
DialogWindowTitle 定义如下:
<style name="DialogWindowTitle"> <item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item> </style>
所以这些都不起作用。谁能告诉我我做错了什么,我该怎么做:
- 更改消息的文本颜色(内容文本)
- 更改标题文本颜色
- 移除面板背景
注意:我需要向上支持 API 8 (2.2)。另外,我在这里和谷歌群组中讨论了大部分相关问题,但无法弄清楚,尽管我感觉它就在我的鼻子底下!
编辑:添加截图: