val keyboardController = LocalSoftwareKeyboardController.current
val activity = LocalContext.current as Activity
Dialog(
onDismissRequest = { onDismiss() },
properties = DialogProperties(usePlatformDefaultWidth = false),
) {
Surface(
modifier = Modifier
.pointerInput(Unit) {
detectTapGestures(onTap = {
keyboardController?.hide()
})
}
.padding(start = 20.dp, end = 20.dp),
shadowElevation = 4.dp
) {
Column(
modifier = Modifier.padding(24.dp)
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
在 onDismiss 中你可以处理这个问题
val keyboardController = LocalSoftwareKeyboardController.current
val focusManager = LocalFocusManager.current
onDismissRequest = { onDismiss()
keyboardController?.hide()
focusManager.clear() },
内柱 使用
Column(
modifier = Modifier
.pointerInput(Unit) {
detectTapGestures(onTap = {
keyboardController?.hide()
focusManager.clear()
})
}
)