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

Lukáš Kúšik

08/22/2022, 6:59 AM
Does anyone know of a way to arrange buttons in a row, in a way where they have equal weights by default, but can also borrow space from other buttons if needed? In this example, the Decide Later button text could fit in a single line if it took some excess space from the Going button.
s

Stylianos Gakis

08/22/2022, 8:15 AM
I don’t think such an arrangement exists by default. The closest thing I’ve done before where things are in a row, but items may take more space than others if needed is this inspired from this discussion. Maybe you can take that and adjust it for your use case
l

Lukáš Kúšik

08/22/2022, 8:24 AM
that's helpful, thank you!
c

Colton Idle

08/22/2022, 10:09 AM
weight(1f, false)
on each one?
s

Stylianos Gakis

08/22/2022, 10:23 AM
How would you then make them also take on the entire width since you’re telling them not to fill it?
c

Colton Idle

08/22/2022, 11:46 AM
yeah. i guess not. /shruggie
f

Francesc

08/22/2022, 6:17 PM
when the attributes on a standard composable do not meet your need it's a sign you may be better off using a
Layout
and rolling your own logic
s

Stylianos Gakis

08/22/2022, 6:30 PM
Tbf there could always be some API you're missing, or maybe there could've been some arrangement which satisfies this need or something like that. Never hurts to ask 😅 Plus now he's got my snippet for free to base his solution off of, win win situation 😅
c

Chris Sinco [G]

08/23/2022, 4:14 AM
I'm not sure what the original design intent is, but having them be equal widths but then taking extra space is more achievable with a custom Layout since you have access to exact measurements. But then you may run into complications when changing locales
Looking at the screenshot you have I'd try to always keep the chip text to one line (assuming this is a chip) and reflow to another line for wider chips
l

Lukáš Kúšik

08/23/2022, 7:16 AM
The intention is to have a single row of buttons at the bottom of a card. Their localized text should stay at one line for as long as it is possible, with them being equal widths by default while being able to "share" space between them if needed.
f

Francesc

08/23/2022, 4:53 PM
you definitively need your custom logic in a Layout for that as you need to measure the intrinsic width to see if they fit, and if they don't, then calculate how much you can allocate to each chip
3 Views