一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Android 隐藏底部虚拟键的两种方法

时间:2022-06-25 22:53:54 编辑:袖梨 来源:一聚教程网

方法一  滑动屏幕 可重新显示出来

protected void hideBottomUIMenu() {
  //隐藏虚拟按键,并且全屏
  if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
    View v = this.getWindow().getDecorView();
    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;
    decorView.setSystemUiVisibility(uiOptions);

  }
}

方法二  滑动也不能重新显示

protected void hideBottomUIMenu() {
  //隐藏虚拟按键,并且全屏
  if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
    View v = this.getWindow().getDecorView();
    v.setSystemUiVisibility(View.GONE);
  } else if (Build.VERSION.SDK_INT >= 19) {
    
    Window _window = getWindow();
    WindowManager.LayoutParams params = _window.getAttributes();
    params.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE;
    _window.setAttributes(params);
  }
}

热门栏目