简体   繁体   English

将textcolor更改为黑色会使对话框标题消失

[英]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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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