我想要自定义AlertDialog按钮的强调颜色。但是似乎没有生效,好像它正在继承系统的颜色。这是我的样式/主题。
<color name="actionable_items">#0574ac</color> <!-- it is blue color -->
<style name="LLDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<!--buttons color-->
<item name="colorAccent">@color/actionable_items</item>
<!--item RadioButton or CheckBox color-->
<item name="colorControlActivated">@color/actionable_items</item>
<item name="colorPrimary">@color/actionable_items</item>
<item name="colorPrimaryDark">@color/actionable_items</item>
<item name="android:listChoiceIndicatorMultiple">@color/actionable_items</item>
<item name="android:listChoiceIndicatorSingle">@color/actionable_items</item>
</style>
这是我的代码,它正在尝试构建AlertDialog对话框。
final CustomPopupBuilder removePlaceDialog = new CustomPopupBuilder(new ContextThemeWrapper(context,
R.style.LLDialog));
removePlaceDialog.setTitle(getString(R.string.delete_place, placeName));
removePlaceDialog.setMessage(getString(R.string.delete_place_message));
removePlaceDialog.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
....
....
}
});
removePlaceDialog.setNegativeButton(R.string.cancel, null);
removePlaceDialog.create().show();
最终的AlertDialog没有相同文本颜色的按钮。 文本颜色类似于绿色。 它似乎是从系统中继承颜色而不是自定义主题。以下是图片:
![enter image description here](https://istack.dev59.com/vmZEi.webp)
final AlertDialog.Builder removePlaceDialog = AlertDialog.Builder(new ContextThemeWrapper(context,
R.style.LLDialog));
removePlaceDialog.setTitle(getString(R.string.delete_place, placeName));
removePlaceDialog.setMessage(getString(R.string.delete_place_message));
removePlaceDialog.setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
....
....
}
});
removePlaceDialog.setNegativeButton(R.string.cancel, null);
removePlaceDialog.create().show();
编辑2:
我还试图更改对话框的强调颜色,但是我没有看到那种颜色:
<style name="LLDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<!--buttons color-->
<item name="colorAccent">#990000</item>
...
...
</style>
即使这样也无法改变按钮文字颜色 :(。
CustomPopupBuilder
而不是默认的AlertDialog
呢..!! - Janki Gadhiya