How to get the blue style text in 2.1 Contacts or Preferences

拟墨画扇 提交于 2019-12-04 21:06:41

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) 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) 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) In your AndroidManifest.xml, apply the new theme to any activity you want:

<activity android:name=".activities.MedicationsActivity"
       android:theme="@style/ActivityStyle">
 </activity>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!