不逼逼,直接上代码
/**
* @param flag
* 控制状态栏显示或者隐藏
*/
void conTrolStatus(boolean flag) {
if (flag) {
//显示状态栏
WindowManager.LayoutParams lp = getWindow().getAttributes();
//LayoutParams.FLAG_FULLSCREEN 强制屏幕状态条栏弹出
lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(lp);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
} else {
//隐藏状态栏
WindowManager.LayoutParams lp2 = getWindow().getAttributes();
//LayoutParams.FLAG_FULLSCREEN 强制屏幕状态条栏弹出
lp2.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(lp2);
//不允许窗口扩展到屏幕之外
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
}
OK,搞定
网友评论