Search code examples
androidandroid-layoutandroid-windowmanager

Button does not react to first tap in fullscreen mode


On the first start of my app I start an Intro-Activity in fullscreen with hidden navigation bar (black bar at the bottom) with:

View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);

The Activity contains a Button to close it.

My problem is: with hidden navigation bar, the first tap on the close-button does not trigger the button, but reveals the navigation bar, only the second tap triggers the button.

Is there a way how I can close the Activity on first button tap?


Solution

  • The answer is described here- https://developer.android.com/training/system-ui/immersive.html. There's a new flag SYSTEM_UI_FLAG_IMMERSIVE that allows this. Unfortunately its KitKat and above only- older phones do not have the capability.