0
我正在制作一个应用程序,使用首选项设置菜单。我有菜单中不同对象的代码,但分隔符是淡白色。我想使它变成更深的颜色(如黑色),以便更容易看到。我当前的代码如下:Android设置自定义偏好分隔线颜色
的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);