Search code examples
androidbackground-colorpreferenceactivity

Android set background color of preference category


I try to customize the background color of preference categories. I already changed the background color of a preferences itself but I can't find a way how to change the the categories background color.

I found two ways but they don't works for me: changing the preference category label color background

Through this link, i found this, but nothing I've tried worked for me. These layout snippet is what I've tried so far:

<resources>
    <style name="setBackgroundTheme" parent="android:Theme">
        <item name="android:background">@color/darkbluelogo</item>
    </style>
</resources>

In onCreate method I set the theme with:

setTheme(R.style.setBackgroundTheme);

Solution

  • Custom a layout file with your background color, set it in your PreferenceCategory:

    <PreferenceCategory
        android:layout="@layout/your_layout">