Android隐藏和显示虚拟导航栏
2018-03-19 本文已影响0人
GexYY
隐藏导航栏
/**
* 隐藏虚拟按键,并且全屏
*/
public static void hideBottomNav(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(0);
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
显示导航栏
/**
* 重新显示导航栏和状态栏
*/
public static void showBottomNav(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(0);
}
沉浸式状态下显示导航栏
/**
*沉浸式全屏状态下,显示导航栏和状态栏
*/
public static void showBottomNav(Activity activity) {
View decorView = activity.getWindow().getDecorView();
decorView.setSystemUiVisibility(0);
decorView .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}