Android 应用在onDeviceReady
事件中返回无效大小 (320x480),但几秒钟后大小变为正确。
我们如何在一开始就获得正确的尺寸?或者有什么活动可以让我获得正确的尺寸吗?
我正在使用这个函数来获取大小:
function getWindowSizes() {
var windowHeight = 0, windowWidth = 0;
if (typeof (window.innerWidth) == 'number') {
windowHeight = window.innerHeight;
windowWidth = window.innerWidth;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
windowHeight = document.documentElement.clientHeight;
windowWidth = document.documentElement.clientWidth;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
windowHeight = document.body.clientHeight;
windowWidth = document.body.clientWidth;
}
return [windowWidth, windowHeight];
}
视口:
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
使用科尔多瓦 2.5.0。
UPD:
正如您在此屏幕截图中看到的,应用程序以较小的尺寸启动。即使是空的 Cordova 项目也会这样做。我怎样才能解决这个问题?
谢谢!