【问题标题】:white theme not showing the text白色主题不显示文字
【发布时间】:2011-04-11 13:24:56
【问题描述】:

我目前正在制作一个可以在两个不同主题之间切换的应用程序(Android 1.6)。 我制作了一个自定义主题,以 Android 轻主题为父主题! 问题是当我切换到白色主题时,我的文本没有被绘制,但如果我选择了一些东西,我可以看到文本。此外,当我切换主题时,我的 titleText、previous 和 next 与我的深色主题中的相同。

这是我用于主题的代码:

<style name="Theme.White" parent="android:Theme.Light"> 
        <item name="android:colorBackground">@color/text_color_dark</item>
        <item name="android:textColor">@color/text_color_dark</item>
        <item name="textPrev">@style/text_prev</item>
        <item name="textRegular">@style/text_regular</item>
        <item name="textTitle">@style/text_title</item>
        <item name="textNext">@style/text_next</item>
        <item name="pageBack">@style/page_back</item>
        <item name="whiteBack">@style/white_back</item>
        <item name="android:textColorPrimaryInverse">@android:color/primary_text_light</item>

    </style>

</resources>  

这是我的风格:

<style name="text_prev">
    <item name="android:textColor">@color/text_color</item>
</style>

<style name="text_next">
    <item name="android:textColor">@color/default_text_color_2</item>
</style>

<style name="text_regular">
    <item name="android:textColor">@color/text_color_dark</item>
</style>

<style name="text_title">
    <item name="android:textColor">@color/text_color_dark</item>
</style>

<style name="page_back">
    <item name="android:background">@drawable/white_background</item>

</style>
<style name="white_back">
    <item name="android:background">@drawable/white_container</item>
    <item name="android:padding">10sp</item>
</style>

我使用了我的 res/drawable 文件夹中的另外两个资源。在标准主题中一切正常,但一旦我切换到我的浅色主题,我的文字就会消失。 是不是我做错了什么?

【问题讨论】:

  • 好的,我做了一些只能部分起作用的事情。在我的 main.xml 中,而不是写 android:textColor/@color/... 我写 style="?normalText" 并且我在 stlyes 中声明了一个样式 normalText_default 和一个 normalText_white。然后我在两个主题中添加一个主题项 normalText。这仅适用于我现在设置黑色 textColor 的白色主题,但我的默认主题对我赋予文本的值没有任何作用。它只是将所有内容设置为灰色/灰白色!

标签: android themes


【解决方案1】:

从上面的代码 sn-p 中,您将背景和文本设置为相同的颜色,即“color/text_color_dark”,它们应该不同。

    <item name="android:colorBackground">@color/text_color_dark</item>
    <item name="android:textColor">@color/text_color_dark</item>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多