Android changing the background color for preference fragment

这一生的挚爱 提交于 2019-12-05 01:05:22

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;
}

you can use a style file or in your PreferenceActivity add this

getListView().setBackgroundColor(Color.rgb(255, 0, 0)); // or whatever color value you want
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!