Home > OS >  How customize AlertDialog with Jetpack Compose?
How customize AlertDialog with Jetpack Compose?

Time:01-05

I want to create a custom AlertDialog making use of Jetpack Compose. I need to put a colored bar for the title as well as different components such as text, radiobuttons ... The end goal is something like this:

enter image description here

In XML layout I know it could be done, but is it possible in Jetpack Compose?

CodePudding user response:

Use Dialog instead of AlertDialog.

https://developer.android.com/reference/kotlin/androidx/compose/ui/window/package-summary#Dialog(kotlin.Function0,androidx.compose.ui.window.DialogProperties,kotlin.Function0)

Inside Dialog you can put any composables you want.

Here is a nice sample:

Show custom alert dialog in Jetpack Compose

  •  Tags:  
  • Related