我使用沉浸式粘性模式隐藏导航栏和操作栏:
当触摸“Spinner”时,将显示“navigationBar”,并禁用沉浸模式。
此解决方案适用于对话框:
@TargetApi(19)
private void setImmersiveMode() {
if (Build.VERSION.SDK_INT >= 19) {
View decorView = getWindow().getDecorView();
int uiOptions = getImmersiveUiOptions(decorView);
decorView.setSystemUiVisibility(uiOptions);
ActionBar actionBar = getActionBar();
if (null!=actionBar) {
actionBar.hide();
}
}
}
当触摸“Spinner”时,将显示“navigationBar”,并禁用沉浸模式。
此解决方案适用于对话框:
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
dialog.show();
dialog.getWindow().getDecorView().setSystemUiVisibility(
context.getWindow().getDecorView().getSystemUiVisibility());
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
但是Spinner
没有可以覆盖的show()
方法。
当触摸Spinner
时,如何防止系统UI显示?
编辑:此问题是关于保持导航栏隐藏(BackButton、HomeButton和RecentTasksButton)。我已经使用了FLAG_FULLSCREEN
。
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);