https://kotlinlang.org logo
#compose
Title
# compose
c

Colton Idle

07/18/2022, 4:53 AM
I'm showing an alert dialog and it looks good out of the box when I do this (it has space between the title and text. As expected
Copy code
AlertDialog(
title = {
    Text(text = "Dialog Title")
}, text = {
Text("Here is a text ") },
But once I replace Text("Here is a text ") with TextField then the space goes away. Trying to add a spacer also doesn't work. Really confused. Ideas?
z

Zoltan Demant

07/18/2022, 7:20 AM
They do some custom layout logic in AlertDialog, it has never really worked great for me - but you can easily copy the source code and replace their logic with a column! Let me know if youd like me to share the resulting code!
c

Colton Idle

07/18/2022, 8:05 AM
Gotcha. Yeah I guess I just could use a Dialog, but I liked the "standardness" of alert dialog (size, background, rounded corners) and was trying not to reinvent the wheel.
z

Zoltan Demant

07/18/2022, 8:28 AM
Ya, I wish it worked better out of the box too. I think I opened an issue for it back in the day but Im not 100% sure. On a positive note, at least the built in Dialog & Surface composables do all the heavy lifting in terms of size, shape, background, and all that jazz 🙂
4 Views