屏幕宽度战:Webview vs Firefox vs Chrome
我在 Android 中使用 webview 制作了一个简单的网络浏览器,但由于某种原因,我得到了不一致的像素比。我还得到了一个错误的 UserAgent,但我已经修复了它。
我在 1080x2400 手机上使用 javascript 使用 window.devicePixelRatio (PR)、window.innerWidth (IW)、screen.width (W)、window.innerHeight (IH)、screen.height (H) 对此进行了测试(您可以检查 此处)。这就是我得到的:
Firefox PR=2.6087 IW=414 W=414 IH=783 H=920
Chrome PR=2.625 IW=412 W=412 IH=778 H=915
Webview PR=2.625 IW=412 W=412 IH=834 H=915
确实 H/W = 2400/1080 = 2.2222。但我对不同的像素比率感到困惑。
对于 Firefox,它似乎正在执行 1080/414,而对于 Chrome,它正在执行 1080/412。
那么,为什么 412 和 414 会有差异呢?应该信任哪一个?
I made a simple web browser with a webview in Android, but for some reason I am getting inconsistent pixelRatios. I also got a wrong UserAgent, but I fixed that already.
I tested this in a 1080x2400 phone with javascript using window.devicePixelRatio (PR), window.innerWidth (IW), screen.width (W), window.innerHeight (IH), screen.height (H) (you can check here). This is what I got:
Firefox PR=2.6087 IW=414 W=414 IH=783 H=920
Chrome PR=2.625 IW=412 W=412 IH=778 H=915
Webview PR=2.625 IW=412 W=412 IH=834 H=915
Indeed H/W = 2400/1080 = 2.2222. But I am confused with the different pixelRatios.
For Firefox, it seems it is doing 1080/414, while for Chrome it is doing 1080/412.
So, why is the difference 412 vs 414? Which one should be trusted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论