Android 11全屏显示

 @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//去掉标题栏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(ActivityLoginBinding.inflate(getLayoutInflater()).getRoot());

//设置全屏
WindowInsetsController controller = getWindow().getInsetsController();
controller.hide(WindowInsets.Type.systemBars());
int behavior3 = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
controller.setSystemBarsBehavior(behavior3);
}

如果有编辑还是显示导航栏的解决方案(重写onWindowFocusChanged):

/**
* 全屏显示
*
* @param hasFocus
*/
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
WindowInsetsController controller = getWindow().getInsetsController();
// 隐藏状态栏 导航栏 同时隐藏状态栏和导航栏
controller.hide(WindowInsets.Type.systemBars());

// 向后模式
int behavior1 = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_TOUCH;
// 沉浸模式
int behavior2 = WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE;
// 粘性沉浸模式
int behavior3 = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE;
controller.setSystemBarsBehavior(behavior3);
}
}

热门相关:首席的独宠新娘   豪门闪婚:帝少的神秘冷妻   别那么骄傲   天启预报   第一神算:纨绔大小姐