弹出键盘时颤动webview黑屏

Posted

技术标签:

【中文标题】弹出键盘时颤动webview黑屏【英文标题】:Flutter webview black screen when keyboard is popping up 【发布时间】:2021-01-16 03:09:51 【问题描述】:

我在我的 android 项目中包含了颤振模块,颤振模块包含我用来加载应用程序 url 的 webview (flutter_inappwebview)

我正在打开一个网页视图页面,其中包含用于输入数据的文本字段。当我点击文本字段输入数据时,键盘弹出,屏幕完全变黑

日志充满以下错误

E/InputMethodManager: b/117267690: Failed to get fallback IMM with expected displayId=134 actual IMM#displayId=0 view=com.pichillilorenzo.flutter_inappwebview.InAppWebView.InAppWebView1df7162 VFEDHVCL. .F...... 0,0-1440,2308

颤动日志

[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale en-IN)
    • Flutter version 1.20.4 at /Users/prabhukuppala/Documents/FlutterDevelopment/flutter
    • Framework revision fba99f6cf9 (2 weeks ago), 2020-09-14 15:32:52 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/prabhukuppala/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • ANDROID_HOME = /Users/prabhukuppala/Library/Android/sdk/platform-tools:/Users/prabhukuppala/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for ios and macOS (Xcode 11.5)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.5, Build version 11E608c
    • CocoaPods version 1.9.1

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2020.1.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 46.0.3
    • Dart plugin version 201.7846.93

[✓] VS Code (version 1.47.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.12.2

[✓] Connected device (2 available)
    • Android SDK built for x86 64 (mobile) • emulator-5554 • android-x64 • Android 8.0.0 (API 26) (emulator)
    • Android SDK built for x86 64 (mobile) • emulator-5556 • android-x64 • Android 10 (API 29) (emulator)

• No issues found!

【问题讨论】:

【参考方案1】:

在脚手架中插入:

resizeToAvoidBottomInset: false

【讨论】:

Perfectt.,在创建条形码扫描仪应用程序时为此苦苦挣扎了几天,它只是一行代码哈哈。谢谢老哥!! 我知道设置为 false 会阻止脚手架主体调整大小以适应键盘,这有时可能是不可取的。有没有办法在保持相机开启的同时允许调整大小?或者没有办法解决它..

以上是关于弹出键盘时颤动webview黑屏的主要内容,如果未能解决你的问题,请参考以下文章

如何在颤动的 webView 中屏蔽广告(移动应用中的网页)

WebView 选择导致软键盘暂时隐藏然后回来

Flutter中 webview的键盘问题解决

颤动:在您离开页面时关闭webview

WebView颤动:初始化url时无法将'cookie'设置为标题

iPhone webview 键盘上推布局并保持不变