Html 当键盘显示 phonegap 时,页面内容不滚动

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16137348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:44:19  来源:igfitidea点击:

page content don't scroll when keyboard shows phonegap

csshtmlcordova

提问by aymen taarit

In my application the registration I have an issue when I try to type in field the keyboard hides the other fields those are the screenshots enter image description here

在我的应用程序中,我在尝试输入字段时遇到问题,键盘隐藏了其他字段,这些字段是屏幕截图 在此处输入图片说明

enter image description here

在此处输入图片说明

how can we fix that I want the page to be scrollable, for info I'm using the phonegap build this needs for sure changes into the config.xml I don't know really how to do it.

我们如何解决我希望页面可滚动的问题,我正在使用 phonegap 构建的信息,这需要确保更改为 config.xml 我真的不知道该怎么做。

回答by Dylan Hamilton-Foster

I had this problem as well - the underlying problem it seems is you can't edit the androidManifest file with Phonegap Build - all you can do is edit the config.xml file which really only allows you to change a limited subset of settings. What I would like (and a lot of others have been screaming for a long time fo) is to be able to change the windowSoftInputMode.

我也遇到了这个问题——潜在的问题似乎是你不能用 Phonegap Build 编辑 androidManifest 文件——你所能做的就是编辑 config.xml 文件,它实际上只允许你更改有限的设置子集。我想要的(以及很多其他人已经尖叫了很长时间)是能够更改 windowSoftInputMode。

I did however find a solution to my problem - which was the keyboard appearing over fields at the bottom of the screen which I think is the same problem you're having. For me - I'm using the latest phonegap 2.7.0 (but was able to reproduce the same behaviour and solution by specifying phonegap 2.5.0 in the config.xml file)

然而,我确实找到了我的问题的解决方案 - 键盘出现在屏幕底部的字段上,我认为这与您遇到的问题相同。对我来说 - 我正在使用最新的 phonegap 2.7.0(但能够通过在 config.xml 文件中指定 phonegap 2.5.0 来重现相同的行为和解决方案)

The solution I found was to change this setting in config.xml

我找到的解决方案是在 config.xml 中更改此设置

<preference name="fullscreen" value="false" />

This does mean you get the 'status bar' at the top of the screen.. which is no biggie for me (in fact I think it's better to have it there.. at least for my app) - with that setting set to "false" instead of "true" - the page now scrolls up to reveal the field you're editing when the keyboard opens. (to be more precise, I believe the viewport changes rather than scroll up)

这确实意味着你会在屏幕顶部看到“状态栏”......这对我来说没什么大不了的(事实上我认为最好把它放在那里......至少对于我的应用程序) - 将该设置设置为“ false" 而不是 "true" - 页面现在向上滚动以在键盘打开时显示您正在编辑的字段。(更准确地说,我相信视口会发生变化而不是向上滚动)

Hope that helps and solves your problem.. took me hours of searching and fiddles to get it to work (if I didn't find that I would have had to abandon phonegap build)

希望能帮助并解决您的问题......花了我几个小时的搜索和摆弄才能让它工作(如果我没有发现我将不得不放弃 phonegap build)

joy! Dylan

喜悦!迪伦

回答by Manuel

Try something like this in config.xml:

尝试这样的事情config.xml

<preference name="fullscreen" value="false" />
<preference name="android-windowSoftInputMode" value="stateVisible" />

回答by Leo Chen

if you use phonegap build

如果你使用 phonegap build

try to add this in config.xml, it helps me out from the same issue:

尝试在 config.xml 中添加它,它可以帮助我解决同样的问题:

<gap:config-file platform="android" parent="/manifest/application">
        android:windowSoftInputMode="stateVisible"
</gap:config-file> 

thanks Manuel to point out the parameter windowSoftInputMode="stateVisible"

感谢 Manuel 指出参数 windowSoftInputMode="stateVisible"