简体   繁体   English

如何在Android中永久隐藏导航栏

[英]How to Hide Navigation Bar Permanently in Android

I am trying to hide navigation bar at bottom in my app. 我正在尝试隐藏应用底部的导航栏。

With following code in my onCreate I can hide it. 在我的onCreate使用以下代码,可以将其隐藏。 But when I press screen or press volume buttons it comes up again. 但是当我按屏幕或按音量按钮时,它又出现了。

View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

How can I permanently hide navigation bar. 如何永久隐藏导航栏。

Add this Code In to Your onCreate() Method it will work for you But android version 4.4 or higher 将此代码添加到您的onCreate()方法中将对您有效,但android 4.4或更高版本

View decor_View = getWindow().getDecorView();

int ui_Options = 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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

decor_View.setSystemUiVisibility(ui_Options);

Hi I did it with using 嗨,我做到了

View.SYSTEM_UI_FLAG_IMMERSIVE and View.SYSTEM_UI_FLAG_IMMERSIVE

SYSTEM_UI_FLAG_HIDE_NAVIGATION flags same time. SYSTEM_UI_FLAG_HIDE_NAVIGATION标志同时显示。

It requires 4.4 but my version is 4.2.2 . 它需要4.4但我的version is 4.2.2

Thats why I couldn't do it before. 那就是为什么我以前做不到。 Thank you all for your answers and consern. 谢谢大家的回答和考虑。

Try this, 尝试这个,

public void FullScreencall() {
    if(Build.VERSION.SDK_INT < 19) { // 19 or above API
        View v = this.getWindow().getDecorView();
        v.setSystemUiVisibility(View.GONE);
    } else {
        //For lower API versions.
        View decorView = getWindow().getDecorView(); 
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
    }
}

Call this method on your onCreate onCreate上调用此方法

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

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