Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android changing the background color for preference fragment

I have set a theme for my application, which includes a blue background...

However, this made my preference fragment blue too. I want to keep the original "android:Theme.Holo.Light.DarkActionBar".

How to do so? thanks!

like image 254
MW_hk Avatar asked May 03 '13 07:05

MW_hk


1 Answers

Add the following code to your PreferenceFragment implementation:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    view.setBackgroundColor(getResources().getColor(android.R.color.your_color));

    return view;
}
like image 63
Diego Acosta Avatar answered Nov 10 '22 10:11

Diego Acosta