Reputation: 121
I have Preference fragment with ListPreference in it. When I click on it, the color of text for "cancel" negative button in the dialog is not good and I need to change it, and I don't know how.
So far I understand that if I put in my theme:
<item name="alertDialogTheme">@style/DialogStyle</item>
That will affect my dialog, but I don't know what to put in style to make my button text change color. I need to only change the color of that button and nothing else.
Anyone know what to do?
Upvotes: 2
Views: 161
Reputation: 439
Just add the following to your styles.xml
.
Add this style with your button-color:
<style name="AlertDialogButton" parent="Widget.MaterialComponents.Button.TextButton.Dialog">
<item name="android:textColor">@color/colorAccent</item>
</style>
The last step is to add those styles in your base-theme of your app (style which the SettingsFragment takes its style from:
<item name="buttonBarPositiveButtonStyle">@style/AlertDialogButton</item>
<item name="buttonBarNegativeButtonStyle">@style/AlertDialogButton</item>
<item name="buttonBarNeutralButtonStyle">@style/AlertDialogButton</item>
Upvotes: 0