【问题标题】:Setting Application theme textColor to white causes Context Menu item text to be white (invisible)将应用程序主题 textColor 设置为白色会导致上下文菜单项文本为白色(不可见)
【发布时间】:2011-04-21 20:51:05
【问题描述】:

好吧,这让我发疯了。为了给我的应用设置皮肤,我在我的主题中设置了以下内容:

<item name="android:textColor">#FFFFFF</item>

应用程序中的所有文本都变成白色,除非我在布局 xmls 中手动覆盖它。太好了,是的,很容易。除了上下文菜单的菜单选项中的文本(不在列表等之外)也决定变成白色。

这不是很好,因为很难在白色上读取白色。我尝试了多种解决方案,包括搜索如何更改上下文菜单的文本颜色(无骰子)以及在我的主题中创建一个 textAppearance 项。最后一个解决方案没有更改我应用程序中的所有文本字段,这令人沮丧。

那么,有什么建议吗?希望我的困境很清楚。

【问题讨论】:

  • 你有没有想过解决这个问题?
  • @Veeti 这对我有用:&lt;style name="AppTheme.Green"&gt; &lt;item name="android:textColor"&gt;@color/greenTextColor&lt;/item&gt;...

标签: android themes contextmenu textcolor


【解决方案1】:

在您的 styles.xml 中尝试覆盖 textViewStyle 而不仅仅是 ALL textColor 属性:

<style name="Theme.Blundell.Light" parent="@android:style/Theme.NoTitleBar">
    <item name="android:windowBackground">@drawable/background_light</item>
    <item name="android:textViewStyle">@style/Widget.TextView.Black</item>
</style>

<style name="Widget.TextView.Black" parent="@android:style/Widget.TextView">
    <item name="android:textColor">#000000</item>
</style>

您甚至可以更进一步,只需覆盖某个视图的颜色,例如按钮:

<style name="Widget.Holo.Button" parent="@android:style/Widget.Holo.Button">
    <item name="android:textColor">#FFFFFF</item>
</style>

<style name="Theme.Blundell" parent="@android:style/Theme.Holo.NoActionBar">
    <item name="android:colorBackground">@android:color/transparent</item>
    <item name="android:buttonStyle">@style/Widget.Holo.Button</item>
</style>

如果您有灵感想要做更多主题,请查看 Android 源代码,这是了解您能做什么和不能做什么的最佳场所!:

https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values

【讨论】:

    【解决方案2】:

    使用这个:

    parent="Theme.AppCompat.Light.DarkActionBar"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 2023-02-25
      • 1970-01-01
      相关资源
      最近更新 更多