change background color of Preference

This worked for me

getListView().setBackgroundColor(Color.TRANSPARENT);

getListView().setCacheColorHint(Color.TRANSPARENT);

getListView().setBackgroundColor(Color.rgb(4, 26, 55));

You can define a theme and then set this for your PreferenceActivity in the manifest. Your theme can then define a a background color or a windowBackground image should you prefer that.

Manifest:

    <activity android:label="@string/app_label" android:name=".client.PreferencesActivity"
        android:theme="@style/PreferencesTheme">
        <intent-filter>                                
        </intent-filter>
    </activity>

Then add the theme to your styles.xml

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

In the above snippet there's both a background color and a background image defined to show how to do it.


android:background is not an available attribute, according to the documentation.

It is possible you could theme the PreferenceActivity to achieve your color change, though I have not tried this, because I want my preferences to look like those of the rest of Android, to improve usability of the app.


Another work-around as far as color goes is that you create a theme for the preferences activity and put the background color of list views as well:

<style name="PrefsTheme" parent="@android:style/Theme.Black.NoTitleBar">
    <item name="android:windowBackground">@color/prefs_bg</item>
    <item name="android:textColor">@color/text_color</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>
</style>