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

Daniele B

10/19/2020, 1:03 PM
Is it possible to make a column “stretchable” ? Let’s say I have 5 columns. I would like the 1st column to be attached to the screen left hand side, the 5th column to be attached to the screen right hand side. I would like to give a fixed width to the 1st, 3rd, 4th and 5th columns. But I would like to allow the 2nd column to take the remaining horizontal space. How can I do that in Compose?
j

Javier

10/19/2020, 1:05 PM
You can use weight
Or you can replace column with constraint layout too
d

Daniele B

10/19/2020, 1:19 PM
What about the modifier
widthIn (min, max)
? Would it push the outer columns to be attached to the screen edges?
z

Zach Klippenstein (he/him) [MOD]

10/19/2020, 1:33 PM
widthIn just sets the min and max width, it won't change how something is sized in relation to other components like that. You don't need constraint layout for this at all:
Copy code
Row(Modifier.fillMaxWidth()) {
  Column (Modifier.width(…)) { … }
  Column (Modifier.weight(1f)) { … }
  Column (Modifier.width(…)) { … }
  Column (Modifier.width(…)) { … }
  Column (Modifier.width(…)) { … }
}
3