我正在尝试为我的警报对话框设置 android Theme.Light 主题,但到目前为止没有成功。在阅读了一些教程后,我发现使用 AlertDialog.Builder 我们无法直接在构造函数中设置主题(至少在 API 级别 7 中)。
我发现的替代解决方案是使用 ContextThemeWrapper,每个人都保证会解决我的问题。所以我编写了这样的代码:
AlertDialog.Builder builder = new AlertDialog.Builder(
new ContextThemeWrapper(context, R.style.popup_theme));
我在 values 文件夹中描述了我的主题:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="back_color">#ffffffff</color>
<style name="popup_theme" parent="@android:style/Theme.Light">
<item name="android:windowBackground">@color/back_color</item>
<item name="android:colorBackground">@color/back_color</item>
</style>
不幸的是,我仍然得到默认的 Theme.Dialog.Alert 主题。谁能告诉我为什么?我哪里错了?
编辑: 如果您不知道我的问题的答案,请投票。我有发布卡住问题的坏习惯:(
最佳答案
将 parent="android:Theme.Light"
更改为 parent="@android:style/Theme.Light"
关于android - 为警报对话框设置 Android Theme.Light,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6729697/