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

Michael Elgavi

02/06/2021, 7:54 PM
How do I make a composable fill remaining space in a
Column
? Tried
fillMaxHeight
but that takes up the entire column
a

Adam Powell

02/06/2021, 7:55 PM
Weight
m

Michael Elgavi

02/06/2021, 7:57 PM
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

Halil Ozercan

02/06/2021, 8:15 PM
If you do not specify weight for one child and give
weight: 1
to another, the other should take the remaining space.
☝️ 3
m

Michael Elgavi

02/06/2021, 8:40 PM
That worked perfectly, thanks!
👍 3
t

TheMrCodes

02/08/2021, 1:36 PM
Are weights the only possibility? Because than (to my knowledge) it only works for child composables of Columns and Rows
a

Adam Powell

02/08/2021, 3:53 PM
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

TheMrCodes

02/08/2021, 4:08 PM
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.
40 Views