问题
Tried a lot of things
<preference name="fullscreen" value="false" />
<preference name="android-windowSoftInputMode" value="adjustResize" />
This seems to be the prefered methods however my keyboard still show on top of my input.
Should adjustResize force the app window to resize? do I need something else?
How can I stop it from hiding my element in position fixed bottom?
Thanks
回答1:
Try something like this:
Add these piece of code in $(document).ready(function() {});
function in your html page where soft keyboard is appearing.
var initialScreenSize = window.innerHeight;
window.addEventListener("resize", function() {
if(window.innerHeight < initialScreenSize){
$("#footer").hide();
document.body.style.position = "fixed";
}
else{
document.body.style.position = "";
$("#footer").show();
}
});
This will might help you.
回答2:
You can detect focused textarea or input then wait a while until keyboard is shown and finally scroll the page to reach focused input. Hope this help you, cheers.
var container = $('body'),
scrollTo = $('#textarea');
setTimeout((function() {
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
});
}), 500);
来源:https://stackoverflow.com/questions/20208463/keyboard-hide-input-positionfixed-bottom0-with-phonegap-on-android