cordova:android 软键盘与输入字段重叠
cordova: android soft keyboard overlapping the input filed
我试过这段代码,但仍然对我不起作用。
当用户点击输入框时,弹出的软键盘会在输入框位于屏幕下方时隐藏输入框。该页面是可滚动的,因此用户可以滚动并再次看到该字段,但客户要求定义页面将自动滚动直到该字段可见。
没有简单的方法可以解决这个问题。我使用这样的处理程序解决了问题:
this.keyboardShowHandler = function (e) {
that.scroll.disable();
that.$el.css('bottom', (e.keyboardHeight - 30) + "px");
that.scroll.refresh();
that.scroll.scrollToElement(document.activeElement, 0, true, true);
};
this.keyboardHideHandler = function () {
setTimeout(function () {
if (!cordova.plugins.Keyboard.isVisible) {
that.$el.css('bottom', "0px");
that.scroll.scrollTo(0, -100, 0);
that.scroll.enable();
that.scroll.refresh();
}
}, 300);
};
window.addEventListener('native.keyboardshow', this.keyboardShowHandler);
window.addEventListener('native.keyboardhide', this.keyboardHideHandler);
但我正在使用 iscroll、jquery 和 cordova 键盘插件。您可能想要适应您的框架
我试过这段代码,但仍然对我不起作用。 当用户点击输入框时,弹出的软键盘会在输入框位于屏幕下方时隐藏输入框。该页面是可滚动的,因此用户可以滚动并再次看到该字段,但客户要求定义页面将自动滚动直到该字段可见。
没有简单的方法可以解决这个问题。我使用这样的处理程序解决了问题:
this.keyboardShowHandler = function (e) {
that.scroll.disable();
that.$el.css('bottom', (e.keyboardHeight - 30) + "px");
that.scroll.refresh();
that.scroll.scrollToElement(document.activeElement, 0, true, true);
};
this.keyboardHideHandler = function () {
setTimeout(function () {
if (!cordova.plugins.Keyboard.isVisible) {
that.$el.css('bottom', "0px");
that.scroll.scrollTo(0, -100, 0);
that.scroll.enable();
that.scroll.refresh();
}
}, 300);
};
window.addEventListener('native.keyboardshow', this.keyboardShowHandler);
window.addEventListener('native.keyboardhide', this.keyboardHideHandler);
但我正在使用 iscroll、jquery 和 cordova 键盘插件。您可能想要适应您的框架