如何获得蓝色样式的文本在2.1联系人或preferences [英] How to get the blue style text in 2.1 Contacts or Preferences

查看:108
本文介绍了如何获得蓝色样式的文本在2.1联系人或preferences的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行Android 2.1,preferences和其他对话框有白/蓝色文本。纵观主题值我看到的东西像textColorPrimary和textColorSecondary。如果我引用这些颜色在我的布局XML,喜欢的东西:

Running Android 2.1, preferences and other dialogs have white/blue text. Looking at theme values I see things like textColorPrimary and textColorSecondary. If I reference those colors in my layout xml, with something like:

  android:textColor="?android:attr/textColorSecondary" 

我只看到白色文字(我曾尝试textColorPrimary,textColorTertiary和textColorHint也)。

I just see white text (I have tried textColorPrimary, textColorTertiary and textColorHint also).

我没有在我的清单文件中所述的任何主题值。我是presuming这意味着我使用的是系统默认主题。

I do not have any theme values stated in my manifest file. I am presuming this means I am using the system default theme.

所有这一切说,我是不是找错了树,文字颜色*参考?

All that said, am I barking up the wrong tree with textColor* references?

推荐答案

所有文字颜色*属性指向的颜色选择的。 如果你想改变颜色的主题,你需要执行以下步骤:

all the textColor* attributes point to color selectors. If you want to change the color for your theme you need to perform the following steps:

1)创建一个颜色选择器,创建一个名为文件(例如)primary_color.xml,并把它在资源\彩色文件夹

1) Create a color selector, create a file named (for example) primary_color.xml and put it under res\color folder

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_enabled="false" android:color="@android:color/bright_foreground_light_disabled"/>
    <item android:state_window_focused="false" android:color="@android:color/bright_foreground_light"/>
    <item android:state_pressed="true" android:color="@android:color/bright_foreground_light"/>
    <item android:state_selected="true" android:color="@android:color/bright_foreground_light"/>
    <item android:color="@android:color/bright_foreground_light"/> <!-- not selected -->

2)在你的styles.xml文件,创建一个主题为您的活动引用新创建的颜色选择:

2) In your styles.xml file, create a theme for your activity that references your newly created color selector:

<style name="ActivityStyle" parent="android:Theme">
        <item name="android:textColorPrimary">@color/primary_color</item>
        <!-- Add more styles here as necessary -->
</style>

3)在你的Andr​​oidManifest.xml中,应用新的主题,以任何你想要的活动:

3) In your AndroidManifest.xml, apply the new theme to any activity you want:

<activity android:name=".activities.MedicationsActivity"
       android:theme="@style/ActivityStyle">
 </activity>

这篇关于如何获得蓝色样式的文本在2.1联系人或preferences的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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