简体   繁体   中英

Changing textcolor to black made dialog title disappear

I am using the following theme for the whole application

<style name="AppTheme" parent="android:Theme.WithActionBar" >
     <item name="android:textColor">#000000</item>        
</style>

The problem that when I display dialog, the title bar dialog is black and since I set the text to be black then the text does not appear. How can I fix this for dialogs? Or at least for a specific dialog?

Thank you

There is a walkthrough on how to do this here

In resources, include this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- AlertDialog text color fix thanks to Shawn Castrianni, see: http://groups.google.com/group/android-developers/browse_thread/thread/f0b34621d3a70c4b -->
<style name="AboutDialog" parent="@android:style/Theme.Dialog">
<item name="android:textColor">?android:attr/textColorPrimaryInverseDisableOnly</item>
</style>
</resources>

To construct your dialog, use this:

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

Or this if you are using a custom layout:

View view = View.inflate(new ContextThemeWrapper(context, R.style.AboutDialog), R.layout.about_dialog, null);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM