相关疑难解决方法(0)

防止键盘出现在 Jetpack Compose 应用程序中

我正在制作一个计算器来学习 Compose,因此我在屏幕上放置了自己的数字按钮,并且我想防止软键盘出现。

这是我的仓库: https: //github.com/vitor-ramos/CalculadorCompose

我注意到 TextFieldImpl.kt 中有一个修饰符来显示键盘,所以我尝试克隆代码并删除该行:keyboardController.value?.showSoftwareKeyboard()我知道复制这样的代码不是一个好主意,但我想尝试一下,并且它不起作用。正如您在下面的原始代码中看到的,有一个 TODO 说它应该由 BaseTextField 处理,但我查看了它的代码,没有找到它显示或隐藏键盘的位置。

val textFieldModifier = modifier
    .focusRequester(focusRequester)
    .focusObserver { isFocused = it.isFocused }
    .clickable(indication = null) {
        focusRequester.requestFocus()
        // TODO(b/163109449): Showing and hiding keyboard should be handled by BaseTextField.
        //  The requestFocus() call here should be enough to trigger the software keyboard.
        //  Investiate why this is needed here. If it is really needed, instead of doing
        //  this in the onClick callback, we should move this logic …
Run Code Online (Sandbox Code Playgroud)

android android-jetpack-compose

9
推荐指数
3
解决办法
9313
查看次数

标签 统计

android ×1

android-jetpack-compose ×1