In my video play app, I use this flag: SYSTEM_UI_FLAG_HIDE_NAVIGATION
to make the navigation bar disappear, but when I touch the screen, the navigation bar appears, after the first touch, my touch events and other events work fine.
My question is how can I take over the first touch?
You may be a developer but you still need to grant that permission to get the full-screen navigation gestures. Now connect your Android device to your computer with a USB cable. You should now see a prompt on your phone to allow USB debugging permission to your computer.
This is how the activity_main.xml looks like: The Navigation Bar needs to have some items which will create using Menu. To create a Menu, first, create a Menu Directory by clicking on the app -> res (right-click) -> New -> Android Resource Directory and select Menu in the Resource Type.
System UI elements are elements like status bar, naviagtion bar etc. SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN helps keep the content from resizing when the system bars hide and show while going in and out of full screen mode. I think setStatusBarColor () needs no explanation. However, this API is available on or above API 21.
Bottom Navigation Bar in Android 1 It allows the user to switch to different activities/fragments easily. 2 It makes the user aware of the different screens available in the app. 3 User is able to check which screen are they on at the moment.
For anyone coming across this post, if your intention is to hide the navigation/status bar and not have it come back up when you touch the screen, take a look at the different "immersive" configurations as described here: https://developer.android.com/training/system-ui/immersive
for example:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or
View.SYSTEM_UI_FLAG_FULLSCREEN or
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
That would effectively put your screen in "Full Screen" Mode regardless of any interaction the user has with the screen
To show the navigation/status bar again, simply change it back to:
currentActivity?.window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With