I am trying to appny immersive mode in one of my fragment, which in managed by a viewPager.
My fragment looks like:
public class MapFragment extends Fragment {
private MapView mMapView;
private GoogleMap googleMap;
private UiSettings mUiSettings;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_map, container, false);
mMapView = rootView.findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
if (getArguments() != null) {
latlang.Lat = getArguments().getDouble("loclat");
latlang.Lang = getArguments().getDouble("loclang");
} else {
latlang.Lat = 23.1;
latlang.Lang = 79.9864;
}
rootView.setSystemUiVisibility(SYSTEM_UI_FLAG_IMMERSIVE
| SYSTEM_UI_FLAG_HIDE_NAVIGATION
| SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| SYSTEM_UI_FLAG_LAYOUT_STABLE
| SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| SYSTEM_UI_FLAG_FULLSCREEN
);
...
Though this works, this is applying to all fragment (i.e. all tabs in the viewPager), which is not intended. So I have 2 question:
- Even when I am applying this specifically to a private view, how is it affecting other view?
- I have tried to manually clean the tags in
onDestroy
method, so that other fragments are not affected, which is not working either.
What I am doing wrong here?
@Override
public void onDestroy() {
super.onDestroy();
mMapView.onDestroy();
showSystemUI();
}
private void showSystemUI() {
View decorView = getActivity().getWindow().getDecorView();
decorView.setSystemUiVisibility(SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}