Is it possible to change background color of Preference

by Vincent » Tue, 16 Feb 2010 19:33:17 GMT

Sponsored Links

Does anybody know how to change the background color of Preference
(PreferenceCategory, EditTextPreference ...) ?

I wanna do like this:
<PreferenceCategory android:title="title_test"
But this doesn't work...
I searched these by using google, but couldn't find any right

Also, I couldn't find any way to change other layouts. (e.g. text
color, size and style of preference title or summary)
Is there no way to customize the layout of Preferences?
It'll be great if somebody can help me out.

thanks in advance!


Is it possible to change background color of Preference

by Bob Kerns » Wed, 17 Feb 2010 00:23:02 GMT

 I think you'll need to supply the android:layout attribute, and supply
an alternative layout with the background set.

You can find the default layout in the SDK at platforms/android-2.1/

If you just want to customize the widget portion, use
android:widgetLayout instead, but this sounds like you want to affect
the entire preference.


Sponsored Links

Is it possible to change background color of Preference

by joebowbeer » Wed, 17 Feb 2010 05:51:28 GMT

 Something like this:

public class MyPreferenceActivity extends PreferenceActivity {

    protected void onCreate(Bundle savedInstanceState) {

I'm not sure if the listView changes are necessary or advisable.



Is it possible to change background color of Preference

by skink » Wed, 17 Feb 2010 07:09:36 GMT


i'm afraid it works only for top-level preferences.

if you have inner ScreenPreferences it won't work as ScreenPreferences
use Dialogs in order to show their child Preferences



Is it possible to change background color of Preference

by Vincent » Wed, 17 Feb 2010 13:31:50 GMT

 Bob, joebowbeer, skink

Thanks so much for your help!!
I successfully managed to change the layout of preference.

As joebowbeer wrote, I changed the top-level background image and
listview setting in my code like below.

Then, I supplied the custom layout to the android:layout attribute in
xml in order to change other child preferences as Bob stated.
    <PreferenceScreen xmlns:android=" 
        <PreferenceCategory android:title="test_title"

Thank you very much!!


Other Threads

1. Mod: Paging ID-Android Surabaya

Bagi rekan-rekan yang punya waktu luang, bisa menyempatkan hadir di acara:

Roadshow Android  "Sosialisasi Kompetisi Aplikasi Android"

Hari/Tgl         : Kamis, 24 Februari 2011
Waktu           : 09.00 - 12.00 WIB
Tempat         : Graha ITS, ITS Surabaya

Narsum        : Kominfo, AH, Perwakilan Kampus ITS


Agus Hamonangan


2. New 3.0 Emulator - Lacking Google Maps API?

I had this same issue when I tried to run my application on the
Samsung Galaxy Tab Add-on; it gets to the install step, but soon after
the Console writes this line: "Installation error:
INSTALL_FAILED_MISSING_SHARED_LIBRARY". I checked my logcat for more
details and found this line in paticular: "Package com.xx.xxxx
requires unavailable shared library;
failing!". Of course, my first thought was that I accidentally set my
build target to the 3.0 Platform, not the Google Apis. After further
investigation though, I found out that I don't even have the Apis for
3.0 (or 2.3.3 for that matter). I went into the SDK and AVD manager to
see if they were available for download, but they are not. So, how are
we supposed to test Map applications on Honeycomb if the supplied 3.0
tools do not have the Google Apis?


3. The return of the curious case of the impossible ArrayIndexOutOfBoundsException

4. last_insert_rowid

5. How to control ViewFlipper in honeycomb app widget?

6. Sharing an email attachment

7. Android Library Projects Cause "already added" from dex