我尝试实现这个布局,但不知道如何操作:
目前它看起来像这样:
使用以下代码:
@Preview(widthDp = 150)
@Composable
fun Item() {
Card(shape = RoundedCornerShape(8.dp)) {
Row {
Box(Modifier.background(Color.Yellow).weight(1f)) {
SomeMoreContentWithUnknownHeight()
}
Box(Modifier.width(20.dp).height(IntrinsicSize.Max).background(Color.Green))
}
}
}
我尝试将第二个框的高度设置为IntrinsicSize.Max,但没有任何变化。我目前正在运行Jetpack Compose 1.0.0-beta07版本。
Modifier.height(IntrinsicSize.Min)
吗? - Ahmed HegazyConstraintLayout
可以将height
设置为Dimension.fillToConstraints
(在View System中只需将height
设置为0dp
),并将top
链接到parent.top
,bottom
链接到parent.bottom
,逻辑容易理解。 - user924ConstraintLayout
使其正常工作。 - user924.height(IntrinsicSize.Min)
设置为容器会破坏此容器内任何ConstraintLayout
的逻辑... - user924