How to change the color of text, text and buttons in AlertDialog and ProgressDialog material

My application extends Theme.AppCompat.Light , and dialogs with a material style appear on a white background, in black text and in green buttons (the counter in ProgessDialog also green).

I would like to change the color and font of the text, as well as the color of the buttons and the counter.

How can i do this?

I found this one , but the XML solution does not work for me, and the rest of the answers are third-party libraries that don't have a ProgressDialog .

Thanks!

+6
source share
1 answer

To get all the “material experience” you must use the latest AppCompat everywhere. Instead of android.app.AlertDialog use android.support.v7.app.AlertDialog for target devices, 21.

Simply setting AppTheme correctly is as follows:

 <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> 
+1
source

Source: https://habr.com/ru/post/978494/


All Articles