简体   繁体   中英

Hide Navigation Bar Permanently

I've followed this thread to hide Navigation bar:

Hide ICS back home task switcher buttons

Works fine when the Activity starts, but whenever I press anywhere on the screen the Navigation bar appears again. I've tried this on an empty Activity without any "views" except the Content View.

How can I hide it throughout the duration of my Activity without having to add some kind of Timer or a Thread to just hide it every millisecond?

It would be great to gain some extra screen size or be able to customize my own Navigation Bar throughout my App.

if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH )
    getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_HIDE_NAVIGATION );
else if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB )
    getWindow().getDecorView().setSystemUiVisibility( View.STATUS_BAR_HIDDEN );

This is a problem that came in a long time when we need to show som content in full screen, bumped the difficulty in being able to hide the status bar on some versions of Android :

Finally Google's latest Android OS , KitKat , introduces a decent user-friendly tool that gives us ownership of that last bit of screen.

Using Immersive Full-Screen Mode see more in : https://developer.android.com/training/system-ui/immersive.html

// This snippet hides the system bars.
private void hideSystemUI() {
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    mDecorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
            | View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
            | View.SYSTEM_UI_FLAG_IMMERSIVE);
}

// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
    mDecorView.setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}

Here's how this has been a thorn in : http://blog.grio.com/2014/02/androids-hiding-of-the-system-bar-fixed.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM