Android的改变颜色与主题 [英] Android changing colors with themes

查看:172
本文介绍了Android的改变颜色与主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想,以提供用户可设置的颜色在我的应用程序。白色文本黑色背景和白底黑字。我有多个布局与许多列表视图,标准和定制的适配器。人建议使用的主题,但我有没有运气在所有布局改变文字颜色。谁能告诉我一个真实主题的布局,能做到这一点?我可以很容易地更改使用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>

这篇关于Android的改变颜色与主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆