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???
CodePudding user response:
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)
)
}