Is it possible to change background color of Preference

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


Sponsored Links
 Hi,

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

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

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/
data/res/layout/preference.xml

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 {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
getWindow().setBackgroundDrawableResource(R.drawable.my_background);
        getListView().setBackgroundColor(Color.TRANSPARENT);
        getListView().setCacheColorHint(Color.TRANSPARENT);
        getPreferenceManager().setSharedPreferencesName("my_prefs");
        addPreferencesFromResource(R.xml.my_preferences);
    }

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

Joe




--



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

pskink

--



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.
 
getWindow().setBackgroundDrawableResource(R.drawable.my_background);
        getListView().setBackgroundColor(Color.TRANSPARENT);
        getListView().setCacheColorHint(Color.TRANSPARENT);

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=" http://schemas.android.com/apk/ 
res/android">
        <PreferenceCategory android:title="test_title"
android:layout="@xml/preference_category">
            <EditTextPreference
                android:key="edit_key"
                android:title="edit_title"
                android:summary="edit_summary"
                android:layout="@xml/preference"
                />
        </PreferenceCategory>
    </PreferenceScreen>


Thank you very much!!








--



Other Threads

1. getting the Froyo kernel source

Hi all,

I want to study the kernel modifications made for Froyo to linux 2.6.32.
Also wanted to check which ones of GKH patches on 2.6.32 are merged into this.

But I can't locate the git location of Froyo kernel. Pls help.

regards,
Suresh

-- 
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: 

2. Task Manager Killing process. Incomplete kill.

Hi all

I am facing following issue with respect to FORCE KILL :

Following is done after BT is on:

1. idle - applications - gallery - camera - Select any one image
2. menu - share - bluetooth - 'scan for devices' touch

After this our task manager app is activated by home key longpress.
i kill Gallery and Opp app.
Now when i push back button , Device picker screen is still displaying.

This is because BluetoothSettings was not killed by taskmanager when opp was
killed.

Can you please suggest any solution for this.

Also When you kill the process , even onPause, onStop or onDestroy is NOT
called.
Is there any function which is called when Force kill of Process is done?!!

Please advice.

Thanks & Regards,
Ajith

-- 

3. Question about rotate bitmap with Canvas.rotate

4. Twitter on 1.5 sense aka hero off of G1

5. Can we send MMS from one emulator to another emulator.

6. GPRS Problem

7. Android porting guidlines for DM6467