Android 沉浸式全屏,不隐藏操作栏和状态栏
我随后使用导航抽屉将沉浸式全屏应用到我的活动中 问题是Actionbar并没有隐藏。对于状态栏,文本只是消失了,而状态的背景色仍然保留在那里 之前 之后 代码Android 沉浸式全屏,不隐藏操作栏和状态栏,android,android-actionbar,android-fullscreen,android-statusbar,Android,Android Actionbar,Android Fullscreen,Android Statusbar,我随后使用导航抽屉将沉浸式全屏应用到我的活动中 问题是Actionbar并没有隐藏。对于状态栏,文本只是消失了,而状态的背景色仍然保留在那里 之前 之后 代码 // This snippet hides the system bars. private void hideSystemUI() { // Set the IMMERSIVE flag. // Set the content to appear under the system bars so
// This snippet hides the system bars.
private void hideSystemUI() {
// Set the IMMERSIVE flag.
// Set the content to appear under the system bars so that the content
// doesn't resize when the system bars hide and show.
View mDecorView = getWindow().getDecorView();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
mIsActionBarVisible = false;
}
// This snippet shows the system bars. It does this by removing all the flags
// except for the ones that make the content appear under the system bars.
private void showSystemUI() {
View mDecorView = getWindow().getDecorView();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
mIsActionBarVisible = true;
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
}
}
请你知道可能出了什么问题吗?我通过显式隐藏ActionBar解决了这个问题:
getSupportActionBar().hide();