Why is my `Switch` outside of the `Row` even thoug...
# compose
Why is my
outside of the
even though the code is inside the block?
Compose UI doesn't clip children by default. Add a clip modifier to the row and you'll see something a bit closer to what you might have expected.
It looks like your column containing the text is consuming all of the available width in the row before the spacer and switch have an opportunity to measure. Give the column a weight modifier and it will measure with the space remaining after the switch and spacer instead.
As far as I remember, adding a weight only to the last Composable should make it take up exactly as much space as it needs and the rest should be taken up by the elements before it. I've done that before. If I set a weight on the Column, I would need to know its exact width beforehand (which I can't)
That's what the
on the Switch is for
No. The parent measures all children without a weight first and allocate the rest space according to the weight value, which means children without a weight will take up exactly as much space as they need.
☝️ 1
👍 1
@Albert Chang But this is what I was just saying
That's why I have the weight only on the last composable
Or how do I get the Switch to take up only the space it needs, and the rest for the Column?
Set the weight on the column
☝️ 1
Thank you, it's working. I guess I remembered that wrong.
@Florian Walther (live streaming) you are a bit stubborn xD This is the same as xml views i guess. You typically do not set the weigh on the things that you don’t want to get overlapped. So you just say: place me the switch, after that use the remaining space for the text