在BottomSheet外部单击后,BottomSheet将隐藏,但小键盘仍保留。我希望在ModalBottomSheetLayout中隐藏BottomSheet后立即删除小键盘
After clicking the text in compose keypad pops upAfter clicking outside bottom sheet, bottom sheet disappears but keypad persists
val state = rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)
val scope = rememberCoroutineScope()
ModalBottomSheetLayout(
sheetContent = {
Column {
var text by remember { mutableStateOf("") }
OutlinedTextField(
value = text,
label = { Text("Text") },
onValueChange = { text = it }
)
var text1 by remember { mutableStateOf("") }
OutlinedTextField(
value = text1,
label = { Text("Text1") },
onValueChange = { text1 = it }
)
OutlinedButton(
onClick = { click() },
) { Text(text = "SUBMIT") }
}
},
sheetState = state,
content = {
Greeting(state = state, scope = scope)
}
)
2条答案
按热度按时间4c8rllxm1#
需要为文本字段添加键盘选项和操作,键盘选项设置键盘类型和键盘上的操作,传递lambda的onAction隐藏底部表单并清除焦点:
8tntrjer2#
当
ModalBottomSheet
隐藏时,您可以尝试隐藏键盘: