I know this is an old question, but I had the exact same problem in my app. The solution I found was fairly simple. (My app is in Angular so I put this in the app.component's ngOnInit
function, but document.ready()
or any other "initialization complete" callback should work just fine with the proper experimentation)
setTimeout(function () {
let viewheight = $(window).height();
let viewwidth = $(window).width();
let viewport = document.querySelector("meta[name=viewport]");
viewport.setAttribute("content", "height=" + viewheight + "px, width=" + viewwidth + "px, initial-scale=1.0");
}, 300);
This forces the viewport meta to explicitly set viewport height, whereas hardcoding
<meta name="viewport"
content="width=device-width, height=device-height, initial-scale=1">
doesn't work because the device-width and device-height change when Android's soft keyboard is opened.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…