我有一个DialogFragment
点击按钮会打开一个AlertDialog
,在这种情况下,dialog
来自此library。当我旋转设备时,我可以让AlertDialog
消失,但它位于DialogFragment
后面。我怎样才能使它保持在它之上?
材料对话框
mDialog = new MaterialDialog.Builder(getContext())
.title(R.string.email_sent)
.content(R.string.check_email)
.inputType(InputType.TYPE_CLASS_NUMBER)
.positiveText(R.string.send)
.negativeText(R.string.cancel)
.inputRange(1, 10, ContextCompat.getColor(getContext(), R.color.red_900))
.input(R.string.activation_code, 0, new MaterialDialog.InputCallback() {
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
dialog.dismiss();
int userActivationCode = Integer.parseInt(input.toString());
peem.setActivationCode(userActivationCode);
mPresenter.createActivationCodePeem(peem);
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
DisplayUtil.keepDialog(mDialog);
保持对话框的轮换更改
public static void keepDialog(MaterialDialog dialog) {
WindowManager.LayoutParams params = new WindowManager.LayoutParams();
params.copyFrom(dialog.getWindow().getAttributes());
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
dialog.getWindow().setAttributes(params);
}