Android 华为虚拟导航栏适配

Android 华为虚拟导航栏适配

在写界面的时候 然后发现在界面最底下的几行文字 正好被虚拟导航栏遮挡住了,不滑动还看不到底下的文字,所以想隐去这些导航栏。
采用下面的代码将DecorView中的属性设置为隐藏 navigation,我这里注销掉了全屏的属性 ,按需添加or删除属性吧

  protected void hideBottomMenu() {
        //隐藏虚拟按键
        if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
            View v = this.getWindow().getDecorView();
            if(v!=null){
                v.setSystemUiVisibility(View.GONE);
            }
        } else if (Build.VERSION.SDK_INT >= 19) {
            //for new api versions.
            View decorView = getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY/* | View.SYSTEM_UI_FLAG_FULLSCREEN*/;
            if (decorView != null) {
                decorView.setSystemUiVisibility(uiOptions);
            }

        }
    }

猜你喜欢

转载自blog.csdn.net/qq_31017737/article/details/80417939