我的這一行有兩個按鈕和一個分隔線。
我已經設定了重量,所以按鈕可以有相同的寬度。
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)
)
}
如果我不將該.height(300.dp)屬性設定為 Row,它就會消失。我不想設定任何硬編碼的高度,我只想讓行有它的“ wrap_content”高度。
我怎樣才能在 Compose 上做到這一點???
uj5u.com熱心網友回復:
用于wrapContentHeight將行換行到內容的高度:
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)
)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/354916.html
標籤:安卓 科特林 安卓布局 android-jetpack-compose android-jetpack-compose-row
上一篇:從左上角到右下角的SVG影片
