列垂直 SpaceBetween 不考虑
Column vertical SpaceBetween not taking into account
无法理解为什么在这张卡片中,在列中,没有考虑垂直对齐的空间。我希望标题位于顶部,“查看详细信息”按钮位于列的底部
fun UserCard(image:Int, text:String, actionButtonLabel:String){
Card(
elevation = 4.dp,
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
.wrapContentHeight()
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.padding(8.dp)
.border(width = 1.dp, color = Color.Blue)
.padding(12.dp)
) {
Image(
painter = painterResource(id = image),
contentDescription = "",
contentScale = ContentScale.Crop,
modifier = Modifier
.size(120.dp)
.clip(CircleShape)
)
Column(
modifier= Modifier.fillMaxHeight(),
horizontalAlignment = Alignment.End,
verticalArrangement = Arrangement.SpaceBetween, // <-- seems not to be taking into account
) {
Title(text)
Button(onClick = { }) {
Text(text = actionButtonLabel)
}
}
}
}
}
UserCard调用示例[=13=]
UserCard(
image= R.drawable.iron,
text = "Live after death",
actionButtonLabel = "View details"
)
您可以将 intrinsic measurements 应用于 Row
容器,将 fillMaxHeight()
修饰符应用于 Column
。
你的问题是列的高度。
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.height(IntrinsicSize.Min)
//..
){
/* Image */
Column(
modifier = Modifier
.fillMaxHeight(),
horizontalAlignment = Alignment.End,
verticalArrangement = Arrangement.SpaceBetween){
//...
}
}
无法理解为什么在这张卡片中,在列中,没有考虑垂直对齐的空间。我希望标题位于顶部,“查看详细信息”按钮位于列的底部
fun UserCard(image:Int, text:String, actionButtonLabel:String){
Card(
elevation = 4.dp,
modifier = Modifier
.padding(12.dp)
.fillMaxWidth()
.wrapContentHeight()
) {
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier
.padding(8.dp)
.border(width = 1.dp, color = Color.Blue)
.padding(12.dp)
) {
Image(
painter = painterResource(id = image),
contentDescription = "",
contentScale = ContentScale.Crop,
modifier = Modifier
.size(120.dp)
.clip(CircleShape)
)
Column(
modifier= Modifier.fillMaxHeight(),
horizontalAlignment = Alignment.End,
verticalArrangement = Arrangement.SpaceBetween, // <-- seems not to be taking into account
) {
Title(text)
Button(onClick = { }) {
Text(text = actionButtonLabel)
}
}
}
}
}
UserCard调用示例[=13=]
UserCard(
image= R.drawable.iron,
text = "Live after death",
actionButtonLabel = "View details"
)
您可以将 intrinsic measurements 应用于 Row
容器,将 fillMaxHeight()
修饰符应用于 Column
。
你的问题是列的高度。
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.height(IntrinsicSize.Min)
//..
){
/* Image */
Column(
modifier = Modifier
.fillMaxHeight(),
horizontalAlignment = Alignment.End,
verticalArrangement = Arrangement.SpaceBetween){
//...
}
}