Dialog fragments
If you need to display any of your fragments floating above the rest of application's UI, then DialogFragment
is perfect for you. All you need to do is define the fragment very similarly to what we did so far. Define the class that is extending DialogFragment
. Override the onCreateView()
method so you can define the layout. You can override onCreate()
as well. The last thing you have to do is to display it as follows:
val dialog = MyDialogFragment() dialog.show(supportFragmentManager, "dialog")
In this example, we passed the instance and the name for the transaction to the fragment manager.