6

My app extends Theme.AppCompat.Light and the material-styled dialogs appear with white background, black text color, and green buttons (spinner in ProgessDialog is also green).

I would like to change the color and font of the text, and also the color of the buttons and spinner.

How can I do it?

I found this post but the XML solution doesn't work for me and the other answers are third party libs that don't have a ProgressDialog.

Thanks!

Community
  • 1
  • 1
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100

1 Answers1

1

To have the whole "Material Experience" you should use the latest AppCompat everywhere. Instead of android.app.AlertDialog use android.support.v7.app.AlertDialog to target devices < 21.

It is enough just to set your AppTheme up correctly like in the following:

<style name="AppTheme" parent="Base.AppTheme">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>

    <!-- This is the interesting part -->
    <item name="android:dialogTheme">@style/AppTheme.Dialog</item>
    <item name="dialogTheme">@style/AppTheme.Dialog</item>
    <item name="android:alertDialogTheme">@style/AppTheme.Dialog</item>
    <item name="alertDialogTheme">@style/AppTheme.Dialog</item>
</style>

<!-- Style the dialog like the normal AppTheme -->
<style name="AppTheme.Dialog" parent="Theme.AppCompat.Light.Dialog">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
</style>
David Medenjak
  • 33,993
  • 14
  • 106
  • 134