1

My project contains one MainActivity and 6 Fragments. I would like to have the layout set to fit system window for 1 certain fragment and not others. So what I did is I put this code getActivity().findViewById(R.id.coordinatorLayout).setFitsSystemWindows(true); inside the onResume method in that one fragment and getActivity().findViewById(R.id.coordinatorLayout).setFitsSystemWindows(false); inside the onResume method in others.

Turn out that the method setFitsSystemWindows(false) works but the setFitsSystemWindows(true) does nothing

The application view still set to not fit System Windows after calling setFitsSystemWindows(true) so I would like to know if I've done anything wrong or the method just can't work.

Thank you in advance. Any answer will be appreciated.

UPDATE: I call .getFitsSystemWindows() after calling .getFitsSystemWindows() and it return true -- without doing the task.

pandaDev
  • 41
  • 2
  • 8
  • The question like this link http://stackoverflow.com/questions/28387289/fitsystemwindows-programmatically-for-status-bar-transparency/40717490#40717490 – Kejie Yuan Nov 21 '16 at 10:10

1 Answers1

-1

If you want to display something under the status bar, try this

getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);

Here is a more detailed solution.

Community
  • 1
  • 1