2014-09-29 161 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" 

根據你改變背景顏色。