我正在尝试为我的警报对话框设置 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主题。谁能告诉我为什么?我哪里错了?
编辑:如果您不知道我的问题的答案,请投票。我有发布卡住问题的坏习惯:(