そのため colorPrimary に黒っぽい色を指定した DayNight テーマだと、Dark Mode のときにボタンの文字が見えないという状態になってしまいます。
- <resources>
- <style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
- <item name="colorPrimary">#212121</item>
- </style>
- </resources>
DayNight テーマの colorPrimary は変えずに Dark Mode のときだけダイアログのボタンの色を変えるには、materialAlertDialogTheme 属性を指定します。
res/values/themes.xml
- <resources>
- <style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
- <item name="colorPrimary">#212121</item>
- <item name="materialAlertDialogTheme">@style/ThemeOverlay.MyApp.MaterialAlertDialog</item>
- </style>
- <style name="ThemeOverlay.MyApp.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog" />
- </resources>
- <resources>
- <style name="ThemeOverlay.MyApp.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
- <item name="colorPrimary">#ffffff</item>
- </style>
- </resources>
0 件のコメント:
コメントを投稿