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

Colton Idle

10/12/2021, 5:53 PM
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

Francesc

10/12/2021, 9:15 PM
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

Colton Idle

10/12/2021, 9:24 PM
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

Colton Idle

10/13/2021, 12:04 AM
Thanks. Keep forgetting how awesome compose docs are. Lol
f

Francesc

10/13/2021, 12:06 AM
Albert beat me to it, but yes, that's it. I believe it's also part of one of the code labs.