如何删除代替窗口导航栏的空白

问题描述

我正在尝试使用https://developer.android.com/training/system-ui/immersive中详细说明的以下代码隐藏窗口NavigationBar,但是为了完全隐藏窗口导航栏,它被恼人的空白所取代,从而阻塞了视图,如图中所示

enter image description here

下面是我的代码

 private int hideSystemsUIBarsInt() {

    if (Build.VERSION.SDK_INT >= 26) {
        return  // Flag type
                View.SYstem_UI_FLAG_IMMERSIVE_STICKY
                        // To Allow the activity content show under the Device Navigation when shown
                       | View.SYstem_UI_FLAG_LAYOUT_STABLE
                       | View.SYstem_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                       | View.SYstem_UI_FLAG_LAYOUT_FULLSCREEN
                        // To Hide the Nav and status bar
                        | View.SYstem_UI_FLAG_HIDE_NAVIGATION
                        | View.SYstem_UI_FLAG_FULLSCREEN
                        // Control the color of the status and navigation item
                        | View.SYstem_UI_FLAG_LIGHT_STATUS_BAR
                        | View.SYstem_UI_FLAG_LIGHT_NAVIGATION_BAR;

    } else { // Flag type
        return
                View.SYstem_UI_FLAG_IMMERSIVE_STICKY
                        // To Allow the activity content show under the Device Navigation when shown
                        | View.SYstem_UI_FLAG_LAYOUT_STABLE
                       | View.SYstem_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYstem_UI_FLAG_LAYOUT_FULLSCREEN
                        // To Hide the Nav and status bar
                        | View.SYstem_UI_FLAG_HIDE_NAVIGATION
                        | View.SYstem_UI_FLAG_FULLSCREEN
                        // Control the color of the status and navigation item
                        | View.SYstem_UI_FLAG_LIGHT_STATUS_BAR;

    }

}

我在如下的onWindowFocusChanged和OnsystemUIVisibilitychangelistener中使用它

 @Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
         decorViewFirst = getwindow().getDecorView();
         decorViewFirst.setsystemUIVisibility(hideSystemsUIBarsInt());
    }
}

 decorViewFirst.setonsystemUIVisibilitychangelistener(new View.OnsystemUIVisibilitychangelistener() {
        @Override
        public void onsystemUIVisibilityChange(int visibility) {
            if (visibility == 0) {
                decorViewFirst = getwindow().getDecorView();
         decorViewFirst.setsystemUIVisibility(hideSystemsUIBarsInt());
            }
        }
    });

任何帮助对帮助我都将大有帮助。请注意,当我为项目实现菜单导航抽屉时,我注意到了这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)