简体   繁体   English

Jetpack compose 软键盘在切换应用程序时打开

[英]Jetpack compose soft keyboard opens up when switching apps

A weird bug in my current app that was created using Jetpack Compose.我当前使用 Jetpack Compose 创建的应用程序中有一个奇怪的错误。

Issue : Once the soft keyboard is opened in the app, due to any screen with TextField , the keyboard is shown every time when switching from a different app to this one.问题:在应用程序中打开软键盘后,由于任何带有TextField的屏幕,每次从不同应用程序切换到此应用程序时都会显示键盘。

视频

Unable to provide a minimal reproducible code as I can't figure out which code is causing this issue and I noticed this quite late as I didn't expect a bug when switching apps.无法提供最小的可重现代码,因为我不知道是哪个代码导致了这个问题,而且我很晚才注意到这一点,因为我没想到切换应用程序时会出现错误。

The whole source code is on Github: https://github.com/Abhimanyu14/finance-manager/tree/main/codebase/android .整个源代码在 Github 上: https ://github.com/Abhimanyu14/finance-manager/tree/main/codebase/android。

Kindly comment if any particular code might help.如果任何特定代码可能有帮助,请发表评论。


Adding keyboard-related code I can think of which might have an impact.添加我能想到的与键盘相关的代码可能会产生影响。

The keyboard is hidden whenever composable navigation happens,每当发生可组合导航时,键盘就会隐藏,

Using LocalSoftwareKeyboardController ,使用LocalSoftwareKeyboardController

val keyboardController = LocalSoftwareKeyboardController.current
keyboardController?.hide()

This was a bug in compose ( https://issuetracker.google.com/issues/225541817 ).这是撰写中的一个错误( https://issuetracker.google.com/issues/225541817 )。 It's fixed as of compose 1.2.0-beta02它从 compose 1.2.0-beta02 开始修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM