【问题标题】:Making a div scrollable after keyboard is shown in a phonegap android app在phonegap android应用程序中显示键盘后使div可滚动
【发布时间】:2014-06-26 12:28:16
【问题描述】:
我正在开发一款平板电脑应用。在主页上,有一个登录详细信息的输入。这个容器 div 是屏幕的整个宽度和高度。当用户点击键盘时,键盘会显示并占据屏幕的下半部分。我现在想让上半部分可滚动。
我编写了一个 phonegap 插件来检测键盘何时显示。在我的 javascript 中,我监听键盘显示事件,然后将容器 div 的高度减少键盘的高度。我还使用overflow: scroll 设置了内部 div。但是,当我这样做时它仍然不可滚动。我正在使用 Android 4.2.2。有什么想法吗?
【问题讨论】:
标签:
javascript
html
css
cordova
【解决方案1】:
我终于用下面的 jQuery Patch 解决了这个问题:
//JS : OnReady event:
var windowHeightSeventyPercent = parseInt(screen.height * 0.7); //To support multiple devices
$("input").focusin(function(){
$("body").height($("body").height()+parseInt(windowHeightSeventyPercent)); //Make page body scroll by adding height to make user to fillup field.
});
$("input").focusout(function(){
$("body").height($("body").height()-parseInt(windowHeightSeventyPercent));
});
Refer this post.