设为首页 加入收藏

TOP

Android 11全屏显示
2023-07-23 13:28:47 】 浏览:20
Tags:Android 全屏显
 @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);
}
}
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇华为运动健康服务Health Kit 6.10.. 下一篇欢迎页轮播动画

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目