Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android full screen mode(ICS), first touch shows the navigation bar

Tags:

android

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?

like image 700
Wesley Avatar asked Feb 27 '13 02:02

Wesley


People also ask

How to enable full screen navigation gestures on Android devices?

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.

How to create a navigation bar in Android?

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.

What is system_UI_flag_layout_fullscreen?

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.

What are the advantages of bottom navigation bar in Android?

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.


1 Answers

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
like image 62
Carlos Conejo Avatar answered Sep 18 '22 14:09

Carlos Conejo