无法在AlertDialog中隐藏导航按钮
在ProgressDialog中完成它-在onStart()中,它可以很好地工作,但是在AlertDialog中,它将无法工作。
public class OwnAlertDialog extends AlertDialog {
protected OwnAlertDialog(Context context) {
super(context);
}
protected OwnAlertDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
public OwnAlertDialog(Context context, int themeResId) {
super(context, themeResId);
}
@Override
public void onStart() {
super.onStart();
Window window = this.getWindow();
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
window.getDecorView().setSystemUiVisibility(uiOptions);
View decorView = getWindow().getDecorView();
decorView.setOnSystemUiVisibilityChangeListener
(visibility -> {
if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) {
decorView.setSystemUiVisibility(uiOptions);
}
});
}
@Override
public void show() {
// Set the dialog to not focusable.
getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
// Show the dialog with NavBar hidden.
super.show();
// Set the dialog to focusable again.
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
}
}
导航按钮显示为隐藏...