【问题标题】:Android Preference Screen LayoutAndroid 首选项屏幕布局
【发布时间】:2011-07-31 03:19:28
【问题描述】:
我的应用中有以下首选项屏幕
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:key="edittexvalue"
android:id="@+id/edittextvalue"
android:title="Title Here"
android:summary="Summary Here"
android:defaultValue="Some Value"/>
<Preference
android:key="customPref"
android:title="Title Here"
android:summary="Summary Here"/>
</PreferenceScreen>
所有这些都很好,但是我的应用程序我有自定义背景和文本颜色/大小,但我不知道如何格式化 PreferenceScreen 我假设你将它指向另一个 xml?但无法弄清楚我需要的代码以及应该进行哪些更改。主要问题是我猜文本的背景颜色很好,但背景与我的应用程序的其余部分不匹配。所以我想设置一个自定义背景颜色让我们现在说红色(#ff0000)
感谢任何可以帮助我解决这个问题的人
【问题讨论】:
标签:
java
android
xml
preferencescreen
【解决方案1】:
您可以在您的manifest 中为其应用theme,例如
<activity android:name=".Settings"
android:theme="@style/YourStyle"/>
并在您的styles.xml 中(如果您没有,请在值文件夹中创建它)
你可以修改任何你需要的东西
例如
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourStyle" parent="android:Theme.Light">
<item name="android:listViewStyle">@style/Widget.ListView</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Widget" parent="android:Widget">
</style>
<style name="Widget.ListView">
<item name="android:background">@color/white</item>
<item name="android:divider">@color/gray_division</item>
<item name="android:dividerHeight">2dip</item>
</style>
</resources>
希望对你有帮助