Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using SystemUiHider to keep the navigation bar hidden

In older versions of Android, it was necessary to use: android:theme="@android:style/Theme.NoTitleBar.Fullscreen" in the manifest to make the title bar disappear.

In the newer ADT versions, I have noticed a SystemUiHider class, which lets you make calls to it's hide() method to remove not only the title bar, but also the action bar and navigation bar.

I am trying to write a fullscreen app, that I would like to stay full screen (for a kiosk implementation), unless a small hidden button is pressed.

I've tried taking the standard FullscreenActivity (generated from the new android project wizard), and prevent the UI from reappearing in a number of ways:

  • Making calls to mSystemUiHider.hide() in the setOnVisibilityChangeListener (to try and immediately hide the UI when it detects a change in visibility)
  • Setting: AUTO_HIDE_DELAY_MILLIS = 0 (to try and immediately hide it if it is visible)
  • Preventing the call to mSystemUiHider.show(); within the onClick method of the contentView.setOnClickListener (to prevent it from being shown)
  • I have also seen the setSystemUiVisibility example in the docs for android.view (again to try and hide it immediately if shown or visibility is changed)

None of them seem to work (Android defaults to the Low Profile Mode for the Navigation Bar when any of these are tried.

I understand that they probably don't want developers doing what I'm trying to do, but I was hoping that I could extend SystemUiHider (and/or SystemUiHiderBase) and override the show() methods to essentially not show unless passed a true flag. I can't seem to find any documentation on either of these classes (perhaps because they're utility classes?).

like image 781
Jono Avatar asked Jan 28 '13 02:01

Jono


People also ask

How do I hide system navigation bar?

Way 1: Touch “Settings” -> “Display” -> “Navigation bar” -> “Buttons” -> “Button layout”. Choose the pattern in “Hide navigation bar” -> When the app opens, the navigation bar will be automatically hidden and you can swipe up from the bottom corner of the screen to show it.

How do I hide the navigation bar while watching a video?

The navigation bar is pinned by default. If you want to view files or use apps in full screen, double-tap the Show and hide button to hide the navigation bar. To show the navigation bar again, drag upwards from the bottom of the screen.

How do I get rid of the navigation bar on my Samsung?

It's a nice mixture of Android 9 Pie and Android 10 gestures. Go through the steps below to make changes. Step 1: Open the Settings app on your Samsung device. Step 2: Navigate to the Display > Navigation Bar > Full screen gestures > More options > Swipe from bottom.


1 Answers

Any interaction with the device brings back the navigation bar.

https://developer.android.com/reference/android/view/View.html#SYSTEM_UI_FLAG_HIDE_NAVIGATION

like image 117
Charles Munger Avatar answered Nov 15 '22 00:11

Charles Munger