强制 DialogFragment 保留在屏幕上

Force a DialogFragment to remain on screen

我想使用 DiaogFragment 显示一个自定义进度对话框,并且我希望它不会在用户点击超出其范围时关闭。我该怎么做?

如果您使用的是 DialogFragment,您可以将对话框设置为不可取消

dialog.setCancelable(false);

试试这个

YourDialogFragment fragment = new YourDialogFragment();
fragment.getDialog().setCanceledOnTouchOutside(false);