Change dialog text color to 5.0+

I am trying to change the color of text in dialogs, most often AlertDialog. I tried every solution on these pages:

AlertDialog styling - how to change the style (color) of the header, message, etc.

How to change the color of the AlertDialog header and the color of the line below it

How to change theme for AlertDialog

Most solutions work BELOW 5.0, but higher, and they do not seem to have any effect. What different attributes should I change to 5.0+?

The main theme of my application is "Theme.AppCompat.Light.NoActionBar"

+7
android dialog
source share
1 answer

In your case, I think that the topic of dialogue will work.

AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.YourDialogStyle; 

You can specify the topic of the dialogue in the same way as the code above.

 <style name="YourDialogStyle" parent="Theme.AppCompat.Light.Dialog"> <item name="android:colorAccent">@color/primary</item> <item name="android:textColor">@color/accent</item> <item name="android:textColorPrimary">@color/primary_dark</item> </style> 

Here is an example of a topic for dialogue.

  • android: colorAccent will affect the text color of the negative or positive buttons.
  • android: textColor will affect the text color of your text.
  • android: textColorPrimary will affect the message color of your dialog.

Another option is that you can create your own layout for the dialogue.

+31
source share

All Articles