Search code examples
androidandroid-dialogfragment

Dialogfragment with multiple related layouts


I want to display a dialog like a wizard style

It has layout1 and then clicking on next display layout2 with its functionality (with transition animation )

Can I create a DialogFragment with multiple Fragments in it? Or do I create multiple DialogFragments? Or perhaps dialog fragment with one layout but nested views under it ?

Other better solution is welcome


Solution

  • Opening multiple DialogFragment one after other does not have a good UX. you can use transaction inside the DialogFragment with animation on a root layout of the dialog.

    fragmentManager.beginTransaction()
                        .setCustomAnimations(android.R.animation.fade_in, android.R.animation.fade_out)
                        .replace(layout, fragment).addToBackStack(tag).commit()
    

    but remember that you have to use minWidth , minHeight maxHeight and maxWidth on the root layout of the dialog, so it wont get bigger or smaller on transaction.