2

My xml code is like this:

 <PreferenceCategory android:title="title">
        <ListPreference 
                    android:title="@string/pref_theme"
                    android:entryValues="@array/pref_theme_values"
                    android:entries="@array/pref_theme_entries"             
                    android:key="theme">
        </ListPreference>
    </PreferenceCategory>

How can I change the color of title here? I am very new to android

  • Please first look for other similar questions before ask a new question! http://stackoverflow.com/questions/19531707/android-how-to-change-listpreference-title-colour and http://stackoverflow.com/questions/10460715/how-to-customize-list-preference-radio-button/14790665#14790665 – PoisonedYouth Apr 10 '15 at 06:05
  • i could not find the answers from your link.. sorry.. Is there any way i can add in xml itself rather than in java? Please tell me – Anupama K N Apr 10 '15 at 06:22

1 Answers1

2

Create a Prefernce Style in your style.xml file and define your Primary Secondary and Tertiary Colors there.

For Example:

<style name="SettingsFragmentStyle">

    <item name="colorPrimary">@color/toolbar_color</item>
    <item name="colorPrimaryDark">@color/toolbar_color_dark</item>
    <item name="android:textColorPrimary">@color/toolbar_color_dark</item>
    <item name="android:textColorSecondary">@color/toolbar_color_dark</item>
    <item name="android:textColorTertiary">@color/toolbar_color_dark</item>
    <item name="android:background">@color/white</item>
    ...
</style>

Then add this Preference theme in your Current AppTheme, like this:

<style name="AppTheme" parent="AppBaseTheme">

    <!-- ALL OTHER THEMES -->
    <item name="preferenceTheme">@style/SettingsFragmentStyle</item>

</style>

I hope this helps.

Salman Khakwani
  • 6,684
  • 7
  • 33
  • 58