0

I'm using the following theme for my dialog:

<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textColorSecondary">@color/colorWhite</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:background">@color/colorPrimary</item>
    <item name="android:textColor">@color/colorWhite</item>
    <item name="android:textColorAlertDialogListItem">@color/colorWhite</item>
</style>

Everything works but the item text color. I need to be white, but for some reason, it remains back. How can I change that text to be white? Thanks

enter image description here

Edit:

Here is my AppTheme:

<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="android:textColorSecondary">@color/colorWhite</item>
</style>
Ivan Patrice
  • 119
  • 9

2 Answers2

1

You may refer AlertDialog Theme: How to change item text color?

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="textColorAlertDialogListItem">@color/colorWhite</item>
</style>

or

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
    <item name="alertDialogTheme">@style/AlertDialogStyle </item>
</style>

<style name="AlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    ...
    <item name="textColorAlertDialogListItem">@color/colorWhite</item>
    <!--
    <item name="android:textColor">@color/colorWhite</item>
    -->
</style>

Also you can change android:textColor, but it will change all the text color in Dialog Window

BlueMist
  • 226
  • 1
  • 7
0

Use your custom DialogBox Style while creating DialogBox.

new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AlertDialogStyle))

Add these lines into your app theme

<item name="android:alertDialogTheme">@style/AlertDialogStyle</item>
<item name="android:alertDialogStyle">@style/AlertDialogStyle</item>
Ranjeet Chouhan
  • 686
  • 5
  • 13