Android dialog z order changes when activity is recreated

Viewed 83

I have an app which can launch a dialog which is implemented as a DialogFragment. This dialog can itself launch another dialog as its child, this other dialog is also implemented using DialogFragment.

The child dialog is shown above the parent dialog correctly when launched, however once the activity is redrawn (e.g. due to an orientation change), the parent dialog is drawn above the child dialog.

So my question is: How can I prevent this change of the dialogs' z order when the activity is redrawn or how can I fix it after the redraw?

This is basically how the child dialog is created by the parent:

ChildDialog child = new ChildDialog();
child.show(getChildFragmentManager(), INVOKED_LOC_SEL_DIALOG_TAG);

I do not want to hide the parent dialog when the child dialog is invoked, as the dialog is not shown again immediately upon calling show(), but instead fades in. I would be fine with that solution if I can suppress the fade animation in this specific case. Requesting focus on any view of the child dialog or explicitly calling show() in the child dialog when it's supposed to be in the foreground did not help me. Using the parent fragment manager also didn't mitigate the problem.

I am using androidx.fragment.app.DialogFragment from androidx.fragment:fragment:1.2.5

0 Answers
Related