Jetpack 组合 LazyColumn 或 Scrollable Column 并且 TextField 的 IME 填充不起作用

问题描述

我正在尝试设置一个列表 if 文本字段,当用户将焦点设置在底部一个文本字段上时,我希望用户可以看到出现的 IME 软键盘和根据配置集填充的文本字段在我的清单文件 android:windowSoftInputMode="adjustPan" 中,但它第一次不起作用,只有当某些列出的文本字段已经有焦点时才起作用。

Behavior in video.

我在 onCreate 方法中的代码

    // Turn off the decor fitting system windows,which allows us to handle insets,// including IME animations
    WindowCompat.setDecorFitsSystemWindows(window,false)

    setContent {

        // Provide WindowInsets to our content. We don't want to consume them,so that
        // they keep being pass down the view hierarchy (since we're using fragments).
        ProvideWindowInsets(consumeWindowInsets = false) {

            MyApplicationTheme {

                // A surface container using the 'background' color from the theme
                Surface(color = MaterialTheme.colors.background,modifier = Modifier.systemBarsPadding()) {

                    Column(modifier = Modifier.fillMaxHeight()) {

                        val list: List<@Composable () -> Unit> = (1..10).map {
                            {

                                Text(text = "$it")

                                Divider()

                                TextField(value = "",onValueChange = {},modifier = Modifier.navigationBarsWithImePadding(),)
                            }
                        }

                        LazyColumn(modifier = Modifier.fillMaxSize().weight(1F)) {

                            itemsIndexed(list) { index,inputText ->

                                inputText()
                            }
                        }
                    }
                }
            }
        }
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)