activity 中设置
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
uiFlags |= 0x00001000;
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
} else {
int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN;
uiFlags |= 0x00001000;
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
}
}
dialog中设置
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus){
int uiFlags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_FULLSCREEN;
uiFlags |= 0x00001000;
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
}
必须同时设置才生效
网友评论