Search code examples
androidkotlinandroid-layoutandroid-jetpack-composeandroid-dialogfragment

Jetpack compose dialogFragment equivalent


I'm trying to implement a dialogFragment with custom layout in Jetpack compose but can't find any samples. Do I need to wrap the UI components inside a Card/Surface and then wrap that inside a Dialog? Can't find any examples in the documentation, all the samples are about Alert dialogs but I need to customise the layout. Thanks.


Solution

  • You can use the Dialog composable:

    Dialog(
        onDismissRequest = { /* ... */ },
        DialogProperties(dismissOnBackPress = true, dismissOnClickOutside = false)
    ) {
        /* Your custom layout */
    }