i have android.support.v4.preference.preferencefragment uses following preferencescreen:
<preferencescreen xmlns:android="http://schemas.android.com/apk/res/android"> <preferencecategory android:title="cat1" android:key="pref_cat1"> <listpreference android:key="pref_list1" android:title="@string/pref_list1" android:dialogtitle="@string/pref_list1" android:entries="@array/pref_list1_entries" android:entryvalues="@array/pref_list1_entries" android:defaultvalue="@string/pref_list1_default"/> <edittextpreference android:key="pref_text2" android:title="@string/pref_text2" /> </preferencecategory> <preferencecategory android:title="cat2" android:key="pref_cat2"> <edittextpreference android:key="pref_text3" android:title="@string/pref_text3" /> </preferencecategory> when displaying preferencefragment, dividers shown between preferences, under name of each preferencecategory. though can modify color of dividers between preferences accessing preferencefragment's listview, has no effect on preferencecategory dividers.
how change color of such dividers?
you have 2 options:
- define
listseparatortextviewstylein app's theme
note else relies on theme attribute change use style define. if that's ok you, this:
<style name="apptheme" parent="android:..."> ... <item name="android:listseparatortextviewstyle">@style/listseparatortext</item> </style> <style name="listseparatortext" parent="android:widget.textview"><!--parent optional --> <item name="android:background">...</item> ... </style> - define custom layout preferencecategories
the default layout preferencecategory textview. can make layout simple or complicated like, somewhere should textview android:id="@android:id/title" title bound automatically.
once have layout, use android:layout attribute in preference xml:
<preferencecategory android:title="cat2" android:key="pref_cat2" android:layout="@layout/my_pref_category"> ... </preferencecategory> alternatively, can define preferencecategorystyle in app's theme, in case don't need use android:layout @ in preference xml.
<style name="apptheme" parent="android:..."> ... <item name="android:preferencecategorystyle">@style/preferencecategorystyle</item> </style> <style name="preferencecategorystyle" parent="android:preference.category"> <item name="android:layout">@layout/my_pref_category</item> ... </style>
Comments
Post a Comment