Talk is cheap, show me the code.
--Linus Torvalds
Okay, here:
private void hideNavigationBar() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
private void showNavigationBar() {
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_VISIBLE;
decorView.setSystemUiVisibility(uiOptions);
}
相关:
SYSTEM_UI_FLAG_VISIBLE——显示状态栏和导航栏
SYSTEM_UI_FLAG_LOW_PROFILE——此模式下,状态栏的图标可能是暗的
SYSTEM_UI_FLAG_HIDE_NAVIGATION——隐藏导航栏
SYSTEM_UI_FLAG_FULLSCREEN——全屏,隐藏状态栏和导航栏
SYSTEM_UI_FLAG_LAYOUT_STABLE
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN——全屏,隐藏导航栏,状态栏浮在布局上。
SYSTEM_UI_FLAG_IMMERSIVE——沉浸式:半透明的状态栏和导航栏
SYSTEM_UI_FLAG_IMMERSIVE_STICKY——粘性沉浸式