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

dimsuz

05/28/2021, 12:20 PM
I suspect this might be an FAQ, but didn't find right away (searched channel + googled)
Copy code
Column {
  Button(modifier = Modifier.fillMaxWidth()) {
    Icon()
    Spacer(weight = 1f)
    Text()
    Spacer(weight = 1f)
  }
}
This works great, but now I also have cases where I want to remove
fillMaxWidth()
and I want both spacers to be equal to
0
width when laid out. I.e. without
fillMaxWidth
I want this button to behave like "wrap_content" in old times: icon + text, centered in column, no space between them. Currently they still stretch, so removing
fillMaxWidth
has no effect and button stretches to full column width. Can this be done?
a

Albert Chang

05/29/2021, 10:32 AM
This can be achieved by a custom
Arrangement
. You can see
Arrangement.SpaceEvenly
and
Arrangement.SpaceBetween
for examples.
d

dimsuz

05/31/2021, 9:45 AM
Great, thank you, I'll check them out!