简体   繁体   中英

How to change ListPreference font colors?

I've made the change to the PreferenceScreen background color to blue, but I can't figure out how to change the font color for ListPreference. I mean the font color on the list. This font color is black in the blue background.

Is there a way to change this font color?

Thank you very much

Edited: added style.xml

<style name="Widget.TextView.ListSeparator" parent="@android:style/Widget.TextView">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:gravity">center_vertical</item>
</style>

<style name="PreferenceListHeader" parent="Widget.TextView.ListSeparator">   
<item name="android:paddingTop">6dp</item>
<item name="android:paddingBottom">6dp</item>
<item name="android:paddingLeft">12dp</item>        
<item name="android:textStyle">bold</item>
<item name="android:textSize">24sp</item> 
<item name="android:textColor">#000000</item>
<item name="android:background">#cccccc</item>          
</style>

<style name="My_Theme" parent="android:Theme">
<item name="android:listSeparatorTextViewStyle">@style/PreferenceListHeader</item>
<item name="android:background">#001EFF</item>
<item name="android:textColorTertiary">#D95869</item>

<item name="android:textColorPrimary">#FF6347</item>         
<item name="android:textColorSecondary">#00FF45</item>     
<item name="android:textSize">24sp</item>                   
</style>

You should define theme for your activity in res/values/styles.xml . android:textColorPrimary , android:textColorSecondary and android:textColorTertiary are what you are looking for.

<style name="PreferencesTheme" parent="android:Theme">
    <item name="android:textColorPrimary">@color/primary</item>
    <item name="android:textColorSecondary">@color/secondary</item>
    <item name="android:textColorTertiary">@color/tertiary</item>
</style>

Then set this theme to activity:

<activity
        android:name="your.package.name.YourPrefActivity"
        android:label="@string/app_name"
        android:theme="@style/PreferencesTheme"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM