在我的三星Galaxy S22+上,使用One UI 5.0和Android 13,compose AlertDialog总是占据整个宽度,而在其他设备上则按预期工作。
Compose版本为1.3.1
您可以通过简单地从Google Play商店下载材料目录应用程序来重现此问题。
我怀疑这很可能是Compose方面的错误,如果有快速修复方法,我将不胜感激。
@Composable
fun AlertDialogSample() {
val openDialog = remember { mutableStateOf(true) }
if (openDialog.value) {
AlertDialog(
onDismissRequest = {
// Dismiss the dialog when the user clicks outside the dialog or on the back
// button. If you want to disable that functionality, simply use an empty
// onCloseRequest.
openDialog.value = false
},
title = {
Text(text = "Title")
},
text = {
Text(
"This area typically contains the supportive text " +
"which presents the details regarding the Dialog's purpose."
)
},
confirmButton = {
TextButton(
onClick = {
openDialog.value = false
}
) {
Text("Confirm")
}
},
dismissButton = {
TextButton(
onClick = {
openDialog.value = false
}
) {
Text("Dismiss")
}
}
)
}
}
更新:
已经创建了一个问题,似乎这是三星方面的一个错误: https://issuetracker.google.com/issues/260755409