[英]cordova misreporting screen.width and screen.height
I have this code in the beginning of my cordova android app 我在Cordova Android应用程序的开头有此代码
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("screen width is " + screen.width + " screen height is " + screen.height);
}
but it is not working as intended: 但它没有按预期工作:
Galaxy Note 3 is total garbage: (should report 1920×1080) Galaxy Note 3完全是垃圾:(应报告1920×1080)
Hisense HS-U980 works fine (should report 1280x720) 海信HS-U980工作正常(应报告1280x720)
It worked with the genymotion emulator, and I have no reason to doubt it would stop working now, this is as far as testing with actual mobile devices went - I am not going further dragging a plethora of handsets into the office from all over until I know why. 它与genymotion模拟器一起使用,我没有理由怀疑它现在是否会停止工作,这是对实际移动设备进行的测试所能做到的-我不会进一步将大量手机从各处拖到办公室知道为什么。 Ideas would be appreciated 想法将不胜感激
I have a same problem two solutions : 我有两个问题相同的解决方案:
you need hard write on you viewport your height and your width. 您需要在视口上硬写高度和宽度。
or you need dynamics rewrite view port with JavaScript. 或者您需要使用JavaScript动态重写视图端口。 You need use DPI device * screen.height and than width. 您需要使用DPI设备* screen.height而不是width。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.