2

Hi I am using custom theme to customize my alert dialog.My problem is when ever i set background color to any color my texts become invisible.Here is my code

<style name="CustomDialogFragment" parent="android:Theme.Dialog">

        <item name="android:windowNoTitle">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:background">@color/black</item>
        <item name="textColorAlertDialogListItem">@color/white</item>

    </style> 

any help will be appreciated and thanks in advance

Neeraj
  • 1,769
  • 3
  • 24
  • 41
Karthik
  • 381
  • 2
  • 10

8 Answers8

6

You need to set

<item name="android:textColor">#54D66A</item> // Add your Hex color code

Edit

You should use android:textColorPrimary

<item name="android:textColorPrimary">#54D66A</item>
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

You have to set color for your text bec yoyr dialog background color and text color is same so text is not visible, set

<item name="android:textColor">#FFFFFF</item>
Naveen Shriyan
  • 1,266
  • 1
  • 9
  • 15
1
        <item name="textColorPrimary">@color/primary_text_dark</item>

try this

Guide Line

Aamir Ali
  • 203
  • 1
  • 8
0

try the below style accordingly:

<style name="AlertDialogCustom" parent="@android:style/Theme.Dialog">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textSize">18sp</item>
    <item name="android:textColorAlertDialogListItem">#FFFFFF</item>
</style>
Rakshit Nawani
  • 2,604
  • 14
  • 27
0

You can achieve it by applying theme to your dialog.

Use android.R.style.Theme_Material_Light_Dialog_Alert as your dialog theme. like this

builder = new AlertDialog.Builder(mContext, android.R.style.Theme_Material_Light_Dialog_Alert);

Hope it will work.

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
Priyavrat
  • 451
  • 3
  • 14
0
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    <style name="CustomDialogFragment"   parent="@android:style/android:Theme.Dialog">
    <item name="android:textColor">#00FF00</item>
    <item name="android:typeface">monospace</item>
    <item name="android:textSize">10sp</item>
    </style>
    </resources>

i think it will be help you..

0

For Android N support you should use :

<item name="android:textColorPrimary">#ffffff</item>
<item name="android:alertDialogTheme">@android:style/Theme.DeviceDefault.Light.Dialog.Alert</item>
Paras G
  • 1
  • 2
0

In my case, the reason is because using the "wrong" layout inflater. Spend the whole day to solve this issue :(

"Wrong" Inflater

LayoutInflater inflater = (LayoutInflater) Navigations.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

"Correct" Inflater

LayoutInflater inflater = mainActivity.getLayoutInflater();