public void hideStatusBar(Activity activity) {
if (activity == null) return;
Window window = activity.getWindow();
if (window == null) return;
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
WindowManager.LayoutParams lp = window.getAttributes();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
}
window.setAttributes(lp);
}
在Activity的setContentView之前调用。
这段代码是一个方法,用于在Android应用中隐藏状态栏。它首先检查Activity是否为空,然后设置Window的全屏标志,并调整装饰视图的系统UI可见性。对于AndroidP及以上版本,处理了显示切口的布局模式。
1608

被折叠的 条评论
为什么被折叠?



