I have two fragments in my activity, fA and fB. When I click a button in fA, fB replaces fA. fB is just like the google play store view, when you open to view some app. The image is under a transparent status bar. I did this by adding this code to fB#onCreateView:
Window w = getActivity().getWindow();
w.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
w.setStatusBarColor(Color.TRANSPARENT);
When I press back, fB is removed and is replace by fA, everything's normal, but the toolbar is under the status bar. Like:
whereas, it should look like:
This is what it looks like when the fragment is first loaded.
Is there any way to clear the flags I set in fB? I've tried to put this code in the onResume of the fragment but no luck!
w.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|View.SYSTEM_UI_FLAG_VISIBLE);
and, i've also tried:
w.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
w.addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
Any other way to fix this? Thank You!