Reputation: 381
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
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
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
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
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
Reputation: 203
<item name="textColorPrimary">@color/primary_text_dark</item>
try this
Upvotes: 1
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
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
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