简体   繁体   English

永久隐藏导航栏

[英]Hide Navigation Bar Permanently

I've followed this thread to hide Navigation bar: 我已遵循此线程来隐藏导航栏:

Hide ICS back home task switcher buttons 隐藏ICS后台任务切换按钮

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. 我已经在一个空的Activity上尝试过此操作,除了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 : 这是很长时间以来出现的一个问题,当我们需要全屏显示som内容时,碰到了在某些版本的Android上隐藏状态栏的困难:

Finally Google's latest Android OS , KitKat , introduces a decent user-friendly tool that gives us ownership of that last bit of screen. 最后,Google最新的Android OS KitKat引入了一个体面的用户友好工具,该工具使我们拥有最后一块屏幕的所有权。

Using Immersive Full-Screen Mode see more in : https://developer.android.com/training/system-ui/immersive.html 使用沉浸式全屏模式,请参见: 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 这是一个棘手的问题: http : //blog.grio.com/2014/02/androids-hiding-of-the-system-bar-fixed.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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