gpt4 book ai didi

android - 如何在 Jetpack Compose 中对齐底部一行?

转载 作者:行者123 更新时间:2023-12-04 23:43:34 25 4
gpt4 key购买 nike

我有一个包含一些行的列,我想在底部对齐最后一行,但是这一行永远不会位于屏幕底部,它保持在前一行之后:

    Column {
// RED BOX
Row(
modifier = Modifier
.fillMaxWidth()
.height(130.dp)
.padding(vertical = 15.dp, horizontal = 30.dp),
verticalAlignment = Alignment.CenterVertically
) {
Column {
Text(
text = stringResource(id = R.string.app_name),
style = TextStyle(fontSize = 40.sp),
color = Color.White
)
Text(
text = stringResource(id = R.string.app_description),
style = TextStyle(fontSize = 13.sp),
fontWeight = FontWeight.Bold,
color = Color.Black
)
}
}

Spacer(
modifier = Modifier
.fillMaxWidth()
.height(15.dp)
)

// GREEN BOX
val currentRoute = currentRoute(navController)
items.forEach { item ->
DrawerItem(item = item, selected = currentRoute == item.route) {
navController.navigate(item.route) {
launchSingleTop = true
}

scope.launch {
scaffoldState.drawerState.close()
}
}
}

Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 15.dp, horizontal = 30.dp),
verticalAlignment = Alignment.Bottom,
horizontalArrangement = Arrangement.Center
) {
Text(
text = BuildConfig.VERSION_NAME,
style = TextStyle(fontSize = 11.sp),
color = Color.Black,
)
}
}
我想得到和我在图片中显示的一样的东西。我想要第一行(红色),然后是第二行(绿色),然后是适合屏幕底部的第三行(蓝色)
enter image description here

最佳答案

您可以通过多种方式做到这一点。
您可以使用带有 verticalArrangement = Arrangement.SpaceBetween 的列分配 weight(1f,false)到最后一行:

  Column(
Modifier.fillMaxHeight(),
verticalArrangement = Arrangement.SpaceBetween) {

//All elements
Column {

// RED BOX

//...
Spacer(
modifier = Modifier
.fillMaxWidth()
.background(Green)
.height(15.dp)
)

//... Green box
}

//LAST ROW
Row(
modifier = Modifier
.weight(1f, false)
) {
//...
}
}
enter image description here

关于android - 如何在 Jetpack Compose 中对齐底部一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70904979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com