Karthik
Karthik

Reputation: 381

Android alert dialog text is not visible

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

Upvotes: 2

Views: 5387

Answers (8)

Abdul Hafidz
Abdul Hafidz

Reputation: 1

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();

Upvotes: 0

Paras G
Paras G

Reputation: 1

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>

Upvotes: 0

Sathish Kumar
Sathish Kumar

Reputation: 1

    <?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..

Upvotes: 0

Priyavrat
Priyavrat

Reputation: 461

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.

Upvotes: 0

Aamir Ali
Aamir Ali

Reputation: 203

        <item name="textColorPrimary">@color/primary_text_dark</item>

try this

Guide Line

Upvotes: 1

IntelliJ Amiya
IntelliJ Amiya

Reputation: 75788

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>

Upvotes: 6

Naveen Shriyan
Naveen Shriyan

Reputation: 1234

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>

Upvotes: 1

Rakshit Nawani
Rakshit Nawani

Reputation: 2604

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>

Upvotes: 0

Related Questions