android - 使用 Jetpack Compose 连续绘制两个按钮
问题描述
我想在 a 中有两个按钮Row
,就像在图片中一样,但是在我的代码中我设置了一个特定的 HorizontalArrangment,它在其他设备上看起来不太好
Row(
horizontalArrangement = Arrangement.spacedBy(170.dp),
modifier = Modifier.fillMaxWidth()
) {
Button(
onClick = { /*TODO*/ },
) {
Text(
modifier = Modifier.padding(8.dp),
text = "Send Email",
style = TextStyle(fontSize = 15.sp)
)
}
Button(
onClick = { /*TODO*/ },
) {
Text(
modifier = Modifier.padding(8.dp),
text = "Call",
style = TextStyle(fontSize = 15.sp)
)
}
}
解决方案
您可以使用horizontalArrangement = Arrangement.SpaceBetween
:
就像是:
Row(
horizontalArrangement = Arrangement.SpaceBetween,
modifier = Modifier.fillMaxWidth().padding(8.dp)
) {
Button( onClick = { /*TODO*/ }){
Text(
text = "Send Email",
style = TextStyle(fontSize = 15.sp)
)
}
Button( onClick = { /*TODO*/ }) {
Text(
text = "Call",
style = TextStyle(fontSize = 15.sp)
)
}
}
推荐阅读
- r - 渲染PDF时如何在R Markdown中进行多列布局?
- deployment - Next.js 中的 `next export` 和 `next build` 有什么区别?
- python - ImportError:numpy.core.multiarray 使用 pytorch 时导入失败
- python - 如何在不和谐 python 机器人中制作画布个人资料卡?
- ios - Instagram 小部件在 iOS 中无法正确加载
- javascript - UnhandledPromiseRejectionWarning:TypeError:无法设置未定义的属性“值”
- python - Pandas Dataframe 如何在特定行之前提取数据行?
- amazon-web-services - Kubernetes,AWS:服务为每个服务创建额外的安全组
- javascript - 如何附加nodejs sequelize json字段的模型列表
- php - 自动更新数据库列 Laravel 中的值