簡體   English   中英

如何更改 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> 

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM