How do I make a composable fill remaining space in...
# compose
m
How do I make a composable fill remaining space in a
Column
? Tried
fillMaxHeight
but that takes up the entire column
a
Weight
m
I have one composable which should "wrap content", and the other should fill the rest of the space. How do I achieve that with weights?
h
If you do not specify weight for one child and give
weight: 1
to another, the other should take the remaining space.
☝️ 3
m
That worked perfectly, thanks!
👍 3
t
Are weights the only possibility? Because than (to my knowledge) it only works for child composables of Columns and Rows
a
Not the only possibility, but there is no universal way to do it without the specific parent layout implementation you're using having a way to say, "measure this child after these others, but lay out in their original order of appearance"
Weight is one such way offered by row and column. Different layouts might offer different variants on it, but we declined to complicate the core layout system of compose UI by requiring every custom layout to implement this or to define a single API shape for doing so.
ConstraintLayout's vocabulary is quite different, for example.
t
ok understood i think it would still be very useful if the were a method that would alow every Node to fit the maxSize available. And it would also be good to have a referend implementation for Column and Row that could be easily adopted for other/custom composables.
Furthermore I personally mainly play around with Compose UI for Desktop and there exists currently no implementation of ConstraintLayout.
1507 Views