2014-09-29 164 views
0

我试图在preferences.xml上更改背景颜色。默认颜色是白色。有没有办法改变它?它也将应用于preferences.xml子屏幕。在preferences.xml上设置背景颜色

在这里,我使用自定义“drawable”来设置背景颜色。可绘制的文件名是bg_gradient.xml。这里是我的代码:

RES /绘制/ bg_gradient.xml

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle" > 

    <gradient 
     android:angle="270" 
     android:gradientRadius="750" 
     android:endColor="@color/bg_gradient_end" 
     android:startColor="@color/bg_gradient_start" 
     android:type="linear" /> 
</shape> 

在此先感谢。

回答

1

添加该代码在styles.xml

<style name="PreferencesTheme"> 
<item name="android:windowBackground">@drawable/background_image</item> 
<item name="android:background">#A4A4A4</item> 
</style> 

,并为SettingsActivity类主题清单。像这样:

android:theme="@style/PreferencesTheme" 

根据你改变背景颜色。