Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide ICS back home task switcher buttons

Just wondering how to hide the ICS back/home/etc software buttons programmatically. Just like the Youtube apps does when playing a video. I want to hide them while a video is playing, but bring them up if the user taps the screen.

I can't seem to find it anywhere on the web, or in Google's documentation.

like image 659
rustyshelf Avatar asked Dec 12 '11 01:12

rustyshelf


3 Answers

pinxue is spot-on... you want SYSTEM_UI_FLAG_HIDE_NAVIGATION. Example:

myView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

One thing to note, though, is that upon any (and I mean ANY) user interaction the navigation bar will be reshown.

With Honeycomb the closest you can get is to go into "lights out" mode (now called "low profile"... SYSTEM_UI_FLAG_LOW_PROFILE ). This just makes the items on the navigation bar less visible (the little "dots" you've probably seen). If you want to do the best you can at maintain backwards compatibility with Honeycomb you can use reflection to use the "best" method:

// Ask the System Bar to hide
int whichHiddenStatusToUse = android.view.View.STATUS_BAR_HIDDEN;
try {
    // if this next line doesn't thrown an exception then we are on ICS or  
    // above, so we can use the new field.
    whichHiddenStatusToUse = View.class.getDeclaredField("SYSTEM_UI_FLAG_HIDE_NAVIGATION").getInt(mDrawingSurface);
} catch (Exception ex) {
}
// now lets actually ask one of our views to request the decreased visibility
myView.setSystemUiVisibility(whichHiddenStatusToUse);
like image 141
Jeremy Logan Avatar answered Oct 28 '22 04:10

Jeremy Logan


try to setup a Full screen window with flag SYSTEM_UI_FLAG_HIDE_NAVIGATION

like image 42
pinxue Avatar answered Oct 28 '22 03:10

pinxue


You want SYSTEM_UI_FLAG_HIDE_NAVIGATION .

This flag was added as of Ice Cream Sandwich, API 14. Previous to 14 a flag STATUS_BAR_HIDDEN was added in Honeycomb, API 11. Previous to that the soft navigation buttons didn't exist, so fullscreen modes were handled entirely by Themes (specifically Theme.NoTitleBar.Fullscreen).

Use:

if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
    mBaseLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
else if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB )
    mBaseLayout.setSystemUiVisibility( View.STATUS_BAR_HIDDEN );
like image 6
reor Avatar answered Oct 28 '22 03:10

reor