Change Preference Screen background color

D.D.M. picture D.D.M. · Oct 3, 2012 · Viewed 10.5k times · Source

I change color PreferenceScreen with this code.But how get Preference Screen in main Preference activity and change Preference Screen color ???

getListView().setBackgroundColor(Color.TRANSPARENT);
    getListView().setCacheColorHint(Color.TRANSPARENT);
    getListView().setBackgroundColor(Color.rgb(4, 26, 55));

Answer

user2195058 picture user2195058 · Mar 25, 2016

You can override OnCreate Method:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        view.setBackgroundColor(getResources().getColor(<COLOR>));
        return view;
    }

Or you can enter the following in styles.xml

<style name="PreferenceTheme" parent="@style/Theme.AppCompat.Light.DarkActionBar">
        <item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
        <item name="android:background">@android:color/white</item>
    </style>