我正在制作一个使用偏好设置菜单的应用。我有菜单中不同对象的代码,但分隔符是淡白色。我想让它变成更深的颜色(如黑色),以便更容易看到。我目前的代码如下:
的preferences.xml:
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="Appearance" />
<ListPreference
android:key="color_scheme"
android:title="Color Scheme"
android:summary="Change the color scheme of the app"
android:dialogTitle="Color Scheme"
android:entries="@array/colors"
android:entryValues="@array/colors"
android:defaultValue="Default (Blue Gray)" />
<PreferenceCategory
android:title="Other" />
<Preference
android:key="@string/preference_reset"
android:title="Reset Values"
android:summary="Reset all values to their default value" />
</PreferenceScreen>
styles.xml:
<style name="PreferenceStyle">
<item name="android:textColorPrimary">@color/text_color_dark</item>
<item name="android:textColorSecondary">@color/text_color_gray</item>
<item name="android:listSeparatorTextViewStyle">@style/ListSeperatorColor</item>
</style>
<style name="ListSeperatorColor" parent="android:Widget.TextView">
<item name="android:background">@color/text_color_dark</item>
</style>
最后:
setTheme(R.style.PreferenceStyle);
答案 0 :(得分:2)
只需将以下内容添加到PreferenceStyle
并删除listSeparatorTextViewStyle
<item name="android:listDivider">@color/text_color_dark</item>
<item name="android:dividerHeight">1dp</item>