Anggrayudi H
Anggrayudi H

Reputation: 15155

Set the background color on preferences.xml

I'm trying to change the background color on preferences.xml. The default color is white. Is there a way to change it? It also will be applied to the preferences.xml subscreens.

Here, I'm using custom "drawable" to set the background color. The drawable file name is bg_gradient.xml. Here is my code:

res/drawable/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>

Thanks in advance.

Upvotes: 0

Views: 3868

Answers (1)

Sats
Sats

Reputation: 885

Add that code in styles.xml

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

and set theme for SettingsActivity class in manifest . like this :

 android:theme="@style/PreferencesTheme"

change background color according to you.

Upvotes: 1

Related Questions