Wrong dpi value for Nexus 7". Bug in the platform, or are we doing something wrong?

心已入冬 提交于 2019-12-12 00:51:41

问题


This code:

activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

is reporting landscape xdpi = 195.38461 on the new Nexus 7. My tape measure says the screen is 1/16" shy of 6" wide, and at 1280 pixels, that works out to 215.57894.

And yes, our Android.xml says:

<uses-sdk android:minSdkVersion="16"/>

Is this just a bug, or are we doing something wrong?


回答1:


From this response from Dianne Hackborn:

Sorry you just can't use them. Nothing in the platform makes use of them. They need to be set by the manufacturer (there is no way for the platform to know what they are), and as of today they are just not consistently set correctly across devices, and because nothing in the platform relies on them it is easy for devices to have them set incorrectly.

Basically, you can't rely on what that returns, at all.



来源:https://stackoverflow.com/questions/12115860/wrong-dpi-value-for-nexus-7-bug-in-the-platform-or-are-we-doing-something-wro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!