Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Preference Screen background color

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));
like image 810
D.D.M. Avatar asked Oct 03 '12 15:10

D.D.M.


2 Answers

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>
like image 166
user2195058 Avatar answered Sep 28 '22 07:09

user2195058


Just extend AppTheme and use colorBackground attribute

<style name="PreferenceTheme" parent="@style/AppTheme">
    <item name="android:colorBackground">@color/colorBackground</item>
</style>
like image 27
Dyno Cris Avatar answered Sep 28 '22 05:09

Dyno Cris