Android的偏好屏幕布局
问题描述:
我在我的应用程序下面的偏好屏幕Android的偏好屏幕布局
<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)
我感谢任何人,可以帮助我解决这个问题
答
你可以申请一个theme
它在你的manifest
,例如
<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>
我希望这有助于
没有考虑使用一个主题,但非常完美的感谢! – GFlam 2011-04-06 22:10:20
没问题,我很高兴它帮助:) – raukodraug 2011-04-06 23:00:33