Android的改变颜色与主题颜色、主题、Android

由网友(firework.(烟火.))分享简介:我想,以提供用户可设置的颜色在我的应用程序。白色文本黑色背景和白底黑字。我有多个布局与许多列表视图,标准和定制的适配器。人建议使用的主题,但我有没有运气在所有布局改变文字颜色。谁能告诉我一个真实主题的布局,能做到这一点?我可以很容易地更改使用myscreen.setBackGroundColor(XX)的背景色,但是当...

我想,以提供用户可设置的颜色在我的应用程序。白色文本黑色背景和白底黑字。我有多个布局与许多列表视图,标准和定制的适配器。人建议使用的主题,但我有没有运气在所有布局改变文字颜色。谁能告诉我一个真实主题的布局,能做到这一点?我可以很容易地更改使用myscreen.setBackGroundColor(XX)的背景色,但是当我尝试用一​​个主题更改文本,它也改变了微调文字以及。

I am trying to provide user settable colors in my app. White text on black background and black text on white background. I have multiple layouts with many listviews, both standard and custom adapters. People have suggested using Themes, but I have had no luck changing the text colors across all layouts. Can anyone show me an actual Theme layout that can accomplish this? I can easily change the background colors using myscreen.setBackGroundColor(xx), but when I try to change the text with a theme, it also changes spinner text as well.

推荐答案

使用

    <item name="android:spinnerStyle">@style/StandardSpinner</item>
    <item name="android:spinnerItemStyle">@style/StandardSpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/StandardSpinnerDropDownItem</item>

在你的主题,这将覆盖文本样式。

in your theme, this will override the Text style.

您的风格会是这个样子:

Your style will look something like this:

<style name="StandardSpinner" parent="@android:style/Widget.Spinner">
    <item name="android:background">@drawable/spinner</item>
</style>

<style name="StandardSpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:textAppearance">@style/GameDisplayText</item>
    <item name="android:gravity">center_vertical|center_horizontal</item>
</style>

<style name="StandardSpinnerDropDownItem" parent="@android:style/Widget.DropDownItem.Spinner">
    <item name="android:textAppearance">@style/GameDisplayText</item>
</style>
阅读全文

相关推荐

最新文章