Using SystemUiHider to keep the navigation bar hidden

Jono picture Jono · Jan 28, 2013 · Viewed 12.8k times · Source

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?).

Answer

Charles Munger picture Charles Munger · Jan 31, 2013

Any interaction with the device brings back the navigation bar.

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