views:

287

answers:

3

Hello all, I have a PreferenceCategory, xml file and I have defined all preferences in it, I call this from class that extends PreferenceActivity. I am unable to set the background of my settings screen , this screen is displayed with help of xml file shown below. Please see that I have already defined the android:background="#041A37", still the screen remains default color :black.

public class MyPreferenceActivity extends PreferenceActivity{
 @Override
public void onCreate(Bundle savedInstanceState) {
Context mContext=super.getBaseContext();
  super.onCreate(savedInstanceState);

  addPreferencesFromResource(R.layout.preference);


  //v.setBackgroundColor(Color.rgb(4, 26, 55));

}
}

preference.xml is

     <?xml version="1.0" encoding="utf-8"?>
      <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
       android:background="#041A37">
  <PreferenceCategory>
  <com.dropcall.SeekBarPreference
            android:key="@string/Interference_Delay"
            android:background="#041A37"
            android:defaultValue="5"
            android:title="Seconds Delay until intereference"
            android:progressDrawable="@drawable/seekbardrawable"/>
    <com.dropcall.SeekBarPreference2
      android:key="@string/Drop_Delay"
            android:defaultValue="30"
             android:progressDrawable="@drawable/seekbardrawable"
            android:title="Seconds delay until drop"
            />  
    <CheckBoxPreference android:key="@string/Drop_Option"
            android:title="Close after call drop"
            android:defaultValue="true"
       android:background="@drawable/state_normal"
            />
    <CheckBoxPreference
            android:key="@string/Timer_Option"
             android:title="Start timers on launch"
       android:background="@drawable/state_normal"
            android:defaultValue="true"/>


Although I have set android:background="#041A37" in every file, the background doesn't turn into navy blue, or any other color for that matter. It remains default color, black. How to change the background color. Please let me know any pointers / hints , if you had faced same issue let me know what changes you made to set the background color.

A: 

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.

CommonsWare
http://stackoverflow.com/questions/3560647/unable-to-inflate-custom-button-through-preferencecategory-xml-file
http://stackoverflow.com/questions/3569412/customize-check-box-preference
+1  A: 

Hello all, This worked for me

        getListView().setBackgroundColor(Color.TRANSPARENT);

        getListView().setCacheColorHint(Color.TRANSPARENT);

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

Or you can also make drawable as your background:

getListView().setBackgroundDrawable(getResources().getDrawable(R.drawable.bluegradient));
Rootko