How to get blue style text in 2.1 Contacts or Preferences

Running Android 2.1, preferences and other dialogs has white / blue text. Looking at topic meanings, I see things like textColorPrimary and textColorSecondary. If I reference these colors in my xml layout, with something like:

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

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

I do not have any topic values ​​specified in my manifest file. I assume that this means that I am using the theme of the standard system.

All that said, I bark the wrong tree using textColor * links

0
source share
1 answer

all textColor * attributes point to a color selector . If you want to change the color for your theme, you need to follow these steps:

1) Create a color selector, create a file with the name (for example) primary_color.xml and put it in the 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 the 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 desired action:

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

Source: https://habr.com/ru/post/1338108/


All Articles