Search code examples
androidandroid-dialogfragmentandroid-architecture-componentsandroid-architecture-navigationmaterial-components-android

Navigation component: Show dialog with rounded corners


I am using the Android navigation component to show a DialogFragment. This also works fine, but now I want to have rounded corners on the dialog.

I've seen here that I could use the MaterialAlertDialogBuilder of the Material Design Components (which my app uses anyways), but as the navigation component displays the DialogFragment for me, I have no access to the DialogBuilder that the navigation component uses? Or is there any way to access it?


Solution

  • Navigation doesn't control what type of dialog is being created - that is the responsibility of the DialogFragment and specifically its onCreateDialog() method.

    It is in onCreateDialog() that you'd use MaterialAlertDialogBuilder to create your dialog with rounded corners.