I would like to present a table like the image bel...
# compose
z
I would like to present a table like the image below, the red column should move left according to the widest cell (the green cell) Currently my layout is
Copy code
Column {
  for (row in rows) {
    Row {
      Text(weight = 1) // align all the spacers to the length of the longest one
      Spacer(width = 20)
      Text()
    }
  }
}
But i am not sure how to go about aligning the spacers according to the longest first
Text()
2
d
You need to measure based on the max intrinsic width of the texts. Something like:
Copy code
val list = listOf("aaaaaaaaaaaaaaaaa", "b", "cccccccc", "ddd")
    Column(Modifier.width(IntrinsicSize.Max)) {
        for (row in 0..3) {
            Row(Modifier.fillMaxWidth()) {
                Text(list[row], Modifier.weight(1f)) 
                Spacer(Modifier.width(20.dp))
                Text("Some other text")
            }
        }
    }