提问人:t3chb0t 提问时间:11/1/2023 更新时间:11/2/2023 访问量:57
具有一列和三行的布局,中间的一行应占用所有剩余空间
Layout with a column and three rows where the middle one should take all the remaining space
问:
我想创建一个 Jetpack Compose Desktop 布局,其中有:
- 按钮顶行
- 中间一排用于内容,占用所有剩余空间
- 状态标签的底行
我试过了这个,但我不知道如何使中间行不将最后一行推到可见区域之外。我是否为此使用了正确的组件?我不确定这是否可以通过列和行来实现,或者我需要其他东西?
@Preview
@Composable
fun AppPreview() {
Box{
Column {
Row(Modifier.border(width = 1.dp, color = Color.Blue).fillMaxWidth()) { Text("top") }
Row(Modifier.border(width = 1.dp, color = Color.Magenta).fillMaxWidth().fillMaxHeight()) { Text("middle") }
Row(Modifier.border(width = 1.dp, color = Color.Green).fillMaxSize()) { Text("bottom") }
}
}
}
答:
1赞
Faruk Karaca
11/2/2023
#1
更新:根据您的评论。
您可以使用基架来处理此问题。
Scaffold(
topBar = {
// top area
},
bottomBar = {
// bottom area
}
) { paddingValues ->
// middle area
Box(modifier = Modifier.padding(paddingValues))
}
评论
0赞
t3chb0t
11/2/2023
这效果很好!如果只有一种方法可以给顶行和底行固定的高度......;-]
0赞
t3chb0t
11/2/2023
魔法!非常好!
1赞
Faruk Karaca
11/2/2023
很高兴我能帮上忙:)
评论