non-Bridge なテーマで MaterialAlertDialogBuilder を使うと、ダイアログのボタンの色は colorPrimaryになります。
そのため colorPrimary に黒っぽい色を指定した DayNight テーマだと、Dark Mode のときにボタンの文字が見えないという状態になってしまいます。
DayNight テーマの colorPrimary は変えずに Dark Mode のときだけダイアログのボタンの色を変えるには、materialAlertDialogTheme 属性を指定します。
res/values/themes.xml
そのため 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>
res/values-night-v8/themes.xml <resources> <style name="ThemeOverlay.MyApp.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog"> <item name="colorPrimary">#ffffff</item> </style> </resources>