how can I make `Column` items same size?
# compose
p
how can I make
Column
items same size?
I've tried this:
Copy code
@Preview
@Composable
private fun Test() {
    Column(
        verticalArrangement = Arrangement.spacedBy(16.dp),
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White),
    ) {
        Text(
            text = "short text",
            modifier = Modifier
                .fillMaxWidth()
                .height(IntrinsicSize.Max)
                .background(Color.Red)
        )
        Text(
            text = "text that\nbreaks",
            modifier = Modifier
                .fillMaxWidth()
                .height(IntrinsicSize.Max)
                .background(Color.Yellow)
        )
    }
}
I'm aware, that I could use "min height", are there any other options?
c
use the same weight for them
p
that expands them to fill the screen? I still want content to wrap.
I basically want red box to expand, to match yellow box size. But I don't want yellow height to change.
I guess I also needed
height(IntrinsicSize.Min)
on my Column
Copy code
@Preview
@Composable
private fun Test() {
    Column(
        modifier = Modifier
            .height(IntrinsicSize.Min)
            .background(Color.White),
    ) {
        Text(
            text = "short text",
            modifier = Modifier
                .fillMaxWidth()
                .weight(1f)
                .background(Color.Red)
        )
        Text(
            text = "text that\nbreaks",
            modifier = Modifier
                .fillMaxWidth()
                .weight(1f)
                .background(Color.Yellow)
        )
    }
}
⬆️ 1
c
What you want to achieve would be much easier with a custom layout
you can measure the elements yourself and then drawing them with the height of the tallest item
p
Are you sure? Simpler than adding 3 modifiers? Can you give me a rough example please?
c
Ahh I just see that in the end it worked with weight and IntrinsicSize.Min height. Never mind then 🙂
p
no worries, thank you for your time
👍 1