【发布时间】:2022-12-01 05:09:24
【问题描述】:
我正面临这个带有 AlertDialog 和 Button 的 fillMaxWidth(fraction = ...) 的奇怪问题,其中 Button 最初以一种尺寸显示,单击时它会缩小以包裹其内容。这是我可以创建的最基本的示例。我尝试过多个版本的 Compose,但它们都做同样的事情。有任何想法吗?
AlertDialog(
modifier = modifier,
onDismissRequest = {},
text = { },
buttons = {
Button(
onClick = { },
modifier = Modifier
.fillMaxWidth(0.75f)
.padding(start = 12.dp, end = 12.dp, bottom = 8.dp)
) {
Text(text = "Done")
}
}
)
点击前:
点击后:
【问题讨论】:
-
如果删除
.fillMaxWidth(0.75f)会发生什么? -
传递给
AlertDialog的修饰符是什么样的?
标签: android android-jetpack-compose android-compose-button android-jetpack-compose-ui