1

In android, the default dialog buttons(Negative, neutral and positive) text color is same as colorAccent(in colors.xml) attribute but I want to set some different color without changing colorAccent attribute. I looked everywhere but I couldn't find any way to do this.

Rahul Roshan
  • 1,501
  • 2
  • 11
  • 14
  • Possible duplicate of [How can I change default dialog button text color in android 5](https://stackoverflow.com/questions/27965662/how-can-i-change-default-dialog-button-text-color-in-android-5) – Amin Mousavi Oct 15 '17 at 21:38
  • this is very different question from what you say it is duplicate @Amin – Rahul Roshan Oct 15 '17 at 22:44

1 Answers1

3

Specify the alertDialogTheme in the main AppTheme, and then define a different colorAccent in that theme, which is specific to AlertDialogs:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="alertDialogTheme">@style/AlertDialog</item>
</style>

<style name="AlertDialog" parent="@style/ThemeOverlay.AppCompat.Dialog.Alert">
    <item name="colorAccent">@color/yourColor</item>
</style>

Daniel Nugent
  • 43,104
  • 15
  • 109
  • 137
Gurgen Hakobyan
  • 951
  • 10
  • 13