Question

In an Android application I added support for exiting immersive view via a single tap. I use the

View.SYSTEM_UI_FLAG_VISIBLE

flag to ensure the fragment gets resized and that action bar doesn't overlap the fragment.

When you exit immersive view via the standard system gesture, the action bar overlaps the fragment. I assume this is due to using the standard flags detailed here under "Using Non-Sticky Immersion" e.g.

// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
    mDecorView.setSystemUiVisibility(
        View.SYSTEM_UI_FLAG_LAYOUT_STABLE
        | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

I would like exiting immersive via the system gesture to behave in the same way as my single tap implementation. Is it possible to override the system UI flags used by the system gesture?

Était-ce utile?

La solution

There is no way override the default gesture flags.

If what you want is to resize your fragment when the system bars become visible, you should register a View.OnSystemUiVisibilityChangeListener to mDecorView. This listener will be notified of system UI changes. Once you get a notification that the bars come visible (whatever the reason) you can do the necessary changes to resize your fragment. See https://developer.android.com/training/system-ui/visibility.html for an example on how the listener can be used.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top