和
<preference name="fullscreen" value="true" />
我需要做以下两个
一个。使用https://github.com/madebycm/AndroidBug5497Workaround/blob/master/AndroidBug5497Workaround.java确保cordova/phonegap可以看到窗口高度的变化
湾。将下面的代码添加到 js 中。这一步是必需的,具体取决于 html 的编写方式
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
document.addEventListener('hidekeyboard', onKeyboardHide, false);
document.addEventListener('showkeyboard', onKeyboardShow, false);
}
function onKeyboardHide() {
console.log('onKeyboardHide');
}
function onKeyboardShow(e) {
console.log('onKeyboardShow');
setTimeout(function() {
e.target.activeElement.scrollIntoViewIfNeeded()
}, 500) //needed timeout to wait for viewport to resize
}