Sergey Maslov
Sergey Maslov

Reputation: 758

Change title text color in PreferenceActivity

In PreferenceActivity we usually have a list, and each item of the list has 3 text fields: title of a "block" of settings (or how you call it), title of an item, summary. For example:

General (block title) -> Notifications (item title) -> Change the sound of notifications (summary).

So my goal is to change the color of title of a block. Im using material theme and already colored all other elements, say, indigo, but this title's color stays teal. I tried this:

 <style name="MyCustomTheme" parent="@style/AppBaseTheme">  
    <item name="android:textColorPrimary">@color/material_indigo</item>
           <item name="android:textColorSecondary">@color/material_indigo</item>
           <item name="android:textColorTertiary">@color/material_indigo</item>
           <item name="android:textColorPrimaryDisableOnly">@color/material_indigo</item>
           <item name="android:textColorHint">@color/material_indigo</item>  
</style> 

NOTHING of this changes color of that bloody title. I use the style above as the app theme by the way. Any thoughts regarding this problem?

Upvotes: 0

Views: 3009

Answers (2)

Sergey Maslov
Sergey Maslov

Reputation: 758

I managed to do it. What I was looking for is this attribute

<item name="android:colorAccent">@color/material_indigo</item>

called "colorAccent".

Upvotes: 2

Mohammad Rababah
Mohammad Rababah

Reputation: 1726

in your themes.xml or styles.xml (better to put it in themes.xml) :

<style name="PreferenceScreen" parent="YourApplicationThemeOrNone">
    <item name="android:textColor">@color/yourCategoryTitleColor</item>
</style>

then in your AndroidManifest.xml :

<activity
      android:name="MyPreferenceActivity"
      ...
      android:theme="@style/PreferenceScreen" >
</activity>

It worked perfectly for me.

Upvotes: 2

Related Questions