我已经花费了很多时间思考这个问题。 我需要做的是更改我的Android应用程序中所有 AlertDialog
的样式 - 对话框背景需要是白色,文本需要是黑色。 我尝试创建了许多样式、主题,并从代码、清单等应用,但对于 AlertDialog
内部的文本颜色没有成功。 现在,我有最简单的代码设置如下:
清单:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
styles.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>
所以这些都不起作用。有人能告诉我我可能做错了什么,以及如何:
- 更改消息的文本颜色(内容文本)
- 更改标题文本颜色
- 删除面板背景
编辑:添加截图: