美文网首页
Android隐藏和显示虚拟导航栏

Android隐藏和显示虚拟导航栏

作者: GexYY | 来源:发表于2018-03-19 10:30 被阅读0次

隐藏导航栏

    /**
     * 隐藏虚拟按键,并且全屏
     */
    public static void hideBottomNav(Activity activity) {
       View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(0);
        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN | 
        View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
        decorView.setSystemUiVisibility(uiOptions);
    }

显示导航栏

     /**
      * 重新显示导航栏和状态栏
      */
    public static void showBottomNav(Activity activity) {
       View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(0);
    }

沉浸式状态下显示导航栏

     /**
      *沉浸式全屏状态下,显示导航栏和状态栏
      */
    public static void showBottomNav(Activity activity) {
       View decorView = activity.getWindow().getDecorView();
        decorView.setSystemUiVisibility(0);
        decorView .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | 
        View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
    }
 

相关文章

网友评论

      本文标题:Android隐藏和显示虚拟导航栏

      本文链接:https://www.haomeiwen.com/subject/ufpuqftx.html