I want to show an AlertDialog (material alert dialog) but have it display my custom composable inside of it. The reasons why I want an alertDialog is because I want the size of an AlertDialog and I want it's container as well (i.e. an alertDialog seems to be on a rounded corner material card)
Should I start with
Dialog
and try to morph it into alertDialog design, or is there a way to pass a composable into an AlertDialog that I'm missing?
l
Louis Pullen-Freilich [G]
05/11/2021, 2:53 PM
Honestly it’s probably easier just to start with a
Dialog
- the implementation is trivial. It’s really just a
Dialog
with a
Surface
with a shape with rounded corners 🙂
c
Colton Idle
05/11/2021, 3:04 PM
@Louis Pullen-Freilich [G] thanks. I was leaning that way, but didn't know if I should just try to make the root element in my dialog a Card or something. Also the Dialog sample code here sets a hardcoded size on the Dialog which I thought was weird.
Copy code
val dialogWidth = 200.dp
val dialogHeight = 50.dp
as I'm used to AlertDialogs in view-land basically always setting it's own size as it promotes consistency throughout the platform.
l
Louis Pullen-Freilich [G]
05/11/2021, 3:07 PM
Yeah, well it’s just a sample of how to use a
Dialog
- you don’t have to set the size 🙂 It should just default to the framework’s default size for consistency.
And yeah, you can just make the root a