我正在尝试通过Styles.xml文件设置“警报”对话框的背景,以便根据用户选择的主题进行更改。我有一个黑暗的主题,这就是为什么文本当前设置为白色,我试图让警报对话框的当前白色背景变黑。
Android Compile Sdk版本:23
爪哇
AlertDialog.Builder about = new AlertDialog.Builder(AboutPreferenceFragment.this.getActivity());
about.setTitle("Title");
about.setMessage("Message");
about.setNeutralButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
about.show();
Styles.xml
<style name="AppThemeDark">
<item name="android:dialogTheme">@style/DialogStyleDark</item>
<item name="android:alertDialogTheme">@style/DialogStyleDark</item>
</style>
<style name="MenuTextApearanceDark" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">@color/White</item>
</style>
<style name="DialogStyleDark" parent="android:Theme.Material.Dialog">
<item name="android:colorAccent">@color/Lime</item>
</style>