How can I make these all the same height? Or maybe...
# compose
c
How can I make these all the same height? Or maybe a more accurate way to put it. How can I make all items in a row, the height of the largest item in the row, while the row itself wraps the content.
Copy code
Row(modifier = Modifier.horizontalScroll(rememberScrollState())) {
    Button(onClick = { /*TODO*/ }, modifier = Modifier.fillMaxHeight().border(1.dp, Color.Green)
    ) { Text(text = "One") }
    Button(onClick = { /*TODO*/ }, modifier = Modifier.fillMaxHeight().border(1.dp, Color.Green)
    ) { Text(text = "Two\nTwo\nTwo") }
    Button(onClick = { /*TODO*/ }, modifier = Modifier.fillMaxHeight().border(1.dp, Color.Green)
    ) { Text(text = "Three") }
}
f
You can use
IntrinsicSize.min
for this
Copy code
Box(modifier = Modifier.height(128.dp).fillMaxWidth()) {
        Row(modifier = Modifier
            .height(IntrinsicSize.Min)
            .horizontalScroll(rememberScrollState())) {
            Button(
                onClick = { /*TODO*/ }, modifier = Modifier
                    .fillMaxHeight()
                    .border(1.dp, Color.Green)
            ) { Text(text = "One") }
            Button(
                onClick = { /*TODO*/ }, modifier = Modifier
                    .fillMaxHeight()
                    .border(1.dp, Color.Green)
            ) { Text(text = "Two\nTwo\nTwo") }
            Button(
                onClick = { /*TODO*/ }, modifier = Modifier
                    .fillMaxHeight()
                    .border(1.dp, Color.Green)
            ) { Text(text = "Three") }
        }
    }
c
Yessssssss. Thank you so much @Francesc! That worked!
jetpack compose 1
👍 2
@Francesc any tips on when to use intrinsic? Never used it before.
c
Thanks. Keep forgetting how awesome compose docs are. Lol
f
Albert beat me to it, but yes, that's it. I believe it's also part of one of the code labs.