2

I have this row with two buttons and one divider.
I had set the weight so the buttons can have the same width.

Row(modifier = Modifier
    .fillMaxWidth()
    .padding(horizontal = 5.dp)
    .height(300.dp)
) {
    Button(
        stringResource(id = R.string.ha_topos_button_description),
        Modifier.weight(1f)
    )
    Divider(whichType = "vertical")
    Button(
        stringResource(id = R.string.ha_gyms_button),
        Modifier.weight(1f)
    )
}

If I don't set the .height(300.dp) property to the Row, it disappears. I don't want to set any hardcoded height, I just want the row to have its "wrap_content" height.
How can I do it on Compose???

Abhimanyu
  • 11,351
  • 7
  • 51
  • 121
juske
  • 95
  • 1
  • 12

1 Answers1

3

Use wrapContentHeight to have the row wrap to the content's height:

Row(modifier = Modifier
    .fillMaxWidth()
    .padding(horizontal = 5.dp)
    .wrapContentHeight()
) {
    Button(
        stringResource(id = R.string.ha_topos_button_description),
        Modifier.weight(1f)
    )
    Divider(whichType = "vertical")
    Button(
        stringResource(id = R.string.ha_gyms_button),
        Modifier.weight(1f)
    )
}
Johann
  • 27,536
  • 39
  • 165
  • 279
  • woow it was quite simple and never thought that. I was trying a lot of difficult things ahah thanks a lot :D – juske Nov 09 '21 at 17:10