If I have a component which is inside a `Row` of `...
# compose
d
If I have a component which is inside a
Row
of `Button`s and then in some situations I pass it
fillMaxWidth
modifier and I want buttons to expand equally inside it, but if no
fillMaxWidth
modifier is used on that component I want them to behave like "wrap content" would, i.e. be of their inrinsic width. Is this possible to achive easily or should I pass some kind of custom parameter to my component for it to change layout accordingly?
c
Do you have a mockup or something similar to illustrate the two versions you are looking for?
☝️ 1
d
Here's the rough description
c
Looks like you just want to apply weight to these buttons. If you give modifier weight 1f to both buttons inside a row, they will be equal sizes. and take up exactly half.
d
I tried it, and if I apply weight then the 3rd case (above) looks like 4th one. I want them to expand only if parent fills max width
c
weight has an additional fill argument. can you try using that?
Copy code
modifier = Modifier.weight(1f, false)
d
it's true by default. I think if i'll make it false... oh, maybe if I'll make it false for the first case, but true for the second case, it'll work. Thanks, I'll try that tomorrow (currently signing off from work 🙂 )
👍 1
It worked, thanks!
🦜 2