简体   繁体   English

Android-Cordova / PhoneGap-键盘在加载和从后台恢复显示

[英]Android - Cordova/PhoneGap - Keyboard Shows on Load & on Resume from Background

I have a Cordova (3.3.0)/PhoneGap application I am building. 我有一个正在构建的Cordova(3.3.0)/ PhoneGap应用程序。

I am having several issues with the keyboard showing in the Android version (issue does not occur on iOS): 我在Android版本中显示键盘时遇到了几个问题(在iOS上不会发生此问题):

  • All devices, the keyboard shows during load, but then hides when the app inits 在加载期间,键盘会显示所有设备,但在应用启动时会隐藏
  • Some devices (Nexus 5 in particular), the keyboard does not hide on init 在某些设备(尤其是Nexus 5)上,键盘在启动时不会隐藏
  • Some devices (again, Nexus 5), the keyboard also shows when the app resumes from background, even if the keyboard was previously hidden 在某些设备(同样是Nexus 5)上,即使以前隐藏了键盘,键盘也会显示应用从后台恢复的时间

Any insight to why this might be? 对为什么会这样有任何见解?

I have the following value in my config.xml (in the root www folder): 我的config.xml(在根www文件夹中)具有以下值:

<preference value="true" name="KeyboardShrinksView"/>

Some other info that might be relevant: 其他一些可能相关的信息:

  • I am using the cordova CLI to build my project 我正在使用cordova CLI来构建我的项目
  • I am using a few plugins, namely: device, dialogs, inappbrowser, network-information 我正在使用一些插件,即:设备,对话框,不兼容的浏览器,网络信息
  • I do have one input control (textbox) on one of my 'pages' in the background (a separate <div> to avoid confusion), but as far as I can tell, this input does not gain focus. 我在后台的一个“页面”中确实有一个输入控件(文本框)(为了避免混淆,使用了单独的<div> ),但是据我所知,此输入没有获得焦点。 I have confirmed this with javascript alerts. 我已使用javascript警报确认了这一点。

Thank you in advance for your time and efforts! 预先感谢您的时间和精力!

Was able to fix my own bug. 能够修复我自己的错误。 It had to do with the AndroidManifest.xml configuration, and not anything Cordova/Phonegap related. 它与AndroidManifest.xml配置有关,与Cordova / Phonegap没有任何关系。 Specifically the 具体来说

android:windowSoftInputMode="stateVisible|adjustPan"

attribute on the activity declaration. 活动声明中的属性。 I can't remember where I found the suggestion for stateVisible , but I believe it was leftover from working through some other keyboard issues. 我不记得在哪里找到有关stateVisible的建议,但我认为它是解决其他键盘问题后遗留下来的。 I adjusted the value to 我将值调整为

android:windowSoftInputMode="stateHidden|adjustPan"

and it fixed the problem. 它解决了这个问题。

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

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