PreferenceFragment background color PreferenceFragment background color android android

PreferenceFragment background color


This question was also answered here

Adding the following code to your PreferenceFragment will let you add a background color, image, etc.

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


Also you can do something like changing the view's background in the onViewCreated() method.

@Overridepublic void onViewCreated(View view, Bundle savedInstanceState) {    super.onViewCreated(view, savedInstanceState);    view.setBackgroundColor(getResources().getColor(R.color.YOUR_COLOR));}


try this.

  @Override  public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {        super.onViewCreated(view, savedInstanceState);        getListView().setBackgroundColor(Color.BLACK);  }