@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void dynamicShowSystemUi(int cur) {
int state = getWindow().getDecorView().getSystemUiVisibility();
L.d(TAG, "dynamicShowSystemUi--------当前-state=" + state);
if (cur == 1) {
state = View.SYSTEM_UI_FLAG_FULLSCREEN;
full(true);
hideSystemUi = true;
} else if (cur == 2) {
state = View.SYSTEM_UI_FLAG_VISIBLE;
full(false);
hideSystemUi = false;
}
getWindow().getDecorView().setSystemUiVisibility(state);
}
private void full(boolean enable) {
if (enable) {
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(lp);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} else {
WindowManager.LayoutParams attr = getWindow().getAttributes();
attr.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(attr);
getWindow().clearFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}SystemUI消失、出现的控制
最新推荐文章于 2026-05-01 10:38:03 发布
本文介绍了一种在Android应用中动态显示与隐藏系统UI的方法,包括全屏模式的切换。通过调整窗口属性实现不同UI状态的快速转换。

380

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



