Search code examples
androidandroid-dialogfragment

Display Android dialog fragment on top of another DialogueFragment?


There is a dialog Fragment visible when my app is launched. When I press back, I want to launch another dialog fragment on top of the current dialog. But my previous dialog gets dismissed. I even overided onDimiss() method to prevent it from dismissal. But still it gets dismissed.I tried with setOncancellable(false). But it makes the back button unresponsive. Is there any way to place a dialogFragment on top of another dialogue? Thanks in advance..


Solution

  • Take a look at both android:gravity and android:layout_gravity.

    Their names should help you:

    android:gravity sets the gravity of the content of the View its used on.

    android:layout_gravity sets the gravity of the View or Layout in its parent.

    Taken from Answer