Khurram
Khurram

Reputation: 41

Change color of preference header list

I am creating an application for android 4.0 tablet with a certain color scheme. I am using Theme.Holo for my activities. I am using Theme.Holo.Light for my PreferenceActivity. I have been able to customize the action bar using styles. I create preference header list using onBuildHeaders method and group different preferences into fragments (much like the android system Settings). I also want to change the color of header list elements to match my application color scheme but I haven't been able to figure out how. Please click on the link to see my preference activity.

Is it possible to change this color scheme and how?

Upvotes: 4

Views: 3783

Answers (1)

Ifrit
Ifrit

Reputation: 6821

Preference headers use the listViewStyle xml attribute to determine it's style. If you'd like to customize that, then override that setting with your own style. Eg:

themes.xml

<style name="Theme.Custom" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:listViewStyle">@style/MyListViewStyle</item>
</style>

styles.xml

<style name="MyListViewStyle" parent="@android:style/Widget.Holo.Light.ListView">
    <item name="android:background">@color/custom_color</item>
    <item name="android:listSelector">@drawable/my_selector</item> 
</style>

Upvotes: 1

Related Questions