Theme.MaterialComponents.Light.DarkActionBar (1.0.0)
Theme.MaterialComponents.Light.DarkActionBar (1.1.0)
何もしてないのに(MDC の version を 1.1.0 に上げたけど...) 色が!変わった!
ピンクはどこの色かというと colorAccent に指定している色です。では緑はどこの色かというと colorPrimary に指定している色です。
ボタン系のデフォルトカラーが 1.1.0 から colorPrimary に変わったようです。
AlertDialog のボタンの色は
?attr/materialAlertDialogTheme に指定されている
ThemeOverlay.MaterialComponents.MaterialAlertDialog
↓
Base.ThemeOverlay.MaterialComponents.MaterialAlertDialog
↓
Base.V14.ThemeOverlay.MaterialComponents.MaterialAlertDialog の
<item name="buttonBarPositiveButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Dialog</item>
<item name="buttonBarNegativeButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Dialog</item>
<item name="buttonBarNeutralButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush</item>
↓
Widget.MaterialComponents.Button.TextButton.Dialog の
<item name="android:textColor">@color/mtrl_text_btn_text_color_selector</item>
↓
@color/mtrl_text_btn_text_color_selector
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="1.00" android:color="?attr/colorPrimary" .../>
<item android:alpha="0.60" android:color="?attr/colorOnSurface" .../>
<item android:alpha="1.00" android:color="?attr/colorPrimary" .../>
<item android:alpha="0.38" android:color="?attr/colorOnSurface"/>
</selector>
あー、colorPrimary と colorOnSurface になったのねぇ。
ちなみに 1.0.0 のときの @color/mtrl_text_btn_text_color_selector では colorAccent 使ってます。
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?attr/colorAccent" android:state_enabled="true"/>
<item android:color="@color/mtrl_btn_text_color_disabled"/>
</selector>
ボタンの色を変えたいときは 「AlertDialog の Negative ボタンの文字色を変える」 と同じ感じでやればOK
<style name="ThemeOverlay.MyApp.MaterialAlertDialog" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="buttonBarPositiveButtonStyle">@style/Widget.MyApp.Button.TextButton.Dialog</item>
<item name="buttonBarNegativeButtonStyle">@style/Widget.MyApp.Button.TextButton.Dialog</item>
</style>
<style name="Widget.MyApp.Button.TextButton.Dialog" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">#1565C0</item>
</style>
AlertDialog.Builder(this, R.style.ThemeOverlay_MyApp_MaterialAlertDialog)
.setTitle("Title")
.setMessage("Message")
.setPositiveButton(android.R.string.ok, null)
.setNegativeButton(android.R.string.cancel, null)
.show()



