kotlin 键盘显示在BottomSheetModal后面,而不是在jetpack合成中显示在其上面

p1tboqfb  于 2023-03-03  发布在  Kotlin
关注(0)|答案(1)|浏览(144)

我正在使用材料3库的ModalBottomSheet,当我想输入OutlinedTextField时,我注意到一个奇怪的行为。这是一个我无法操纵的奇怪问题。

Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally,
        verticalArrangement = Arrangement.Center
    ) {
        Row(
            Modifier.toggleable(
                value = skipHalfExpanded,
                role = Role.Checkbox,
                onValueChange = { checked -> skipHalfExpanded = checked }
            )
        ) {
            Checkbox(checked = skipHalfExpanded, onCheckedChange = null)
            Spacer(Modifier.width(16.dp))
            Text("Skip Half Expanded State")
        }
        Button(onClick = { openBottomSheet = !openBottomSheet }) {
            Text(text = "Show Bottom Sheet")
        }
    }

// Sheet content
    if (openBottomSheet) {
        ModalBottomSheet(
            onDismissRequest = { openBottomSheet = false },
            sheetState = bottomSheetState,
        ) {
            Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) {
                Button(
                    // Note: If you provide logic outside of onDismissRequest to remove the sheet,
                    // you must additionally handle intended state cleanup, if any.
                    onClick = {
                        scope.launch { bottomSheetState.hide() }.invokeOnCompletion {
                            if (!bottomSheetState.isVisible) {
                                openBottomSheet = false
                            }
                        }
                    }
                ) {
                    Text("Hide Bottom Sheet")
                }
            }
            InputTextField()
        }
    }

任何解决办法都将受到赞赏。

4ioopgfo

4ioopgfo1#

我还没有在Material 3中执行此操作;但是如果您重新安排您的实现使其看起来更像这样会发生什么呢?

ModalBottomSheetLayout(
    sheetState = sheetState,
    sheetContent = { YourBottomSheet() }
) {
    YourPrimaryScreen()
}

相关问题