Does anyone know of a way to arrange buttons in a ...
# compose
l
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
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
that's helpful, thank you!
c
weight(1f, false)
on each one?
s
How would you then make them also take on the entire width since you’re telling them not to fill it?
c
yeah. i guess not. /shruggie
f
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
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
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
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
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