我目前正在尝试为首选项屏幕设置自定义背景。我创建了PreferenceActivity
public class SettingsActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
}
}
这是我的偏好布局
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
>
<CheckBoxPreference
android:key="pref_Autoplay"
android:title="@string/pref_Autoplay"
android:summary="@string/pref_Autoplay_summ"
android:defaultValue="false"/>
<ListPreference
android:entryValues="@array/pref_Voice_values"
android:entries="@array/pref_Voice_entries"
android:key="pref_Voice"
android:summary="Choose male or female reader"
android:title="Readers voice"
android:defaultValue="female"/>
</PreferenceScreen>
当我在这里阅读以更改背景时,我需要创建自己的风格主题。这里是:
<style name="PrefsTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/prefs_bg</item>
<item name="android:textColor">@color/prefs_bg</item>
<item name="android:listViewStyle">@style/listViewPrefs</item>
</style>
<style name="listViewPrefs" parent="@android:style/Widget.ListView">
<item name="android:background">@color/prefs_bg</item>
<item name="android:cacheColorHint">@color/prefs_bg</item>
<item name="android:textColor">@color/prefs_bg</item>
</style>
我只需要为首选项列表设置一些图像背景。我的形象是@drawable/prefs_bg
。当我设置windowBackground
为图像和background
某种颜色时,首选项列表背景使用颜色而不是图片。但是,当我将背景设置为首@drawable/prefs_bg
选项列表背景时,我的图片和单选按钮对话框出现在我的ListPreference
项目中也使用图像背景。
请帮忙,如何在不影响某些首选项项目的单选按钮对话框背景的情况下为首选项列表设置图像背景?