如何更改 MaterialAlertDialog 主题

How to change MaterialAlertDialog theme

这是一个对话框,如何更改颜色(未选中)?

我尝试设置样式但不起作用:

 <style name="ThemeMyAppDialogAlertDay"  
   parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
    <item name="colorPrimary">@color/color_secondary</item>
    <item name="colorPrimaryVariant">@color/color_primary_variant</item>
    <item name="colorOnPrimary">@color/color_secondary</item>
    <item name="colorSecondary">@color/color_secondary</item>
    <item name="colorAccent">@color/color_error</item>
</style>

试试这个,应该会有帮助

<style name="materialDiaog" parent="MaterialAlertDialog.MaterialComponents">
    <item name="buttonTint">@color/colorPrimary</item>
    <item name="colorPrimary">@color/color_secondary</item>
    <item name="colorPrimaryVariant">@color/color_primary_variant</item>
    <item name="colorOnPrimary">@color/color_secondary</item>
    <item name="colorSecondary">@color/color_secondary</item>
    <item name="colorAccent">@color/color_error</item>


</style>
<style name="AppTheme" parent="{set your parent theme here}">
    <item name="materialAlertDialogTheme">@style/materialDiaog</item>
</style>

您可以使用:

 <style name="ThemeMyAppDialogAlertDay"  
   parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
     <item name="colorSecondary">@color/selected</item> <!-- selected -->
     <item name="colorControlNormal">@color/unselected</item> <!-- unselected -->
 </style>