10 inch tablet with 149 PPI is showing as 160 dpi in program

我怕爱的太早我们不能终老 提交于 2019-12-12 02:58:49

问题


Samsung galaxy 10 inch tablet spec is saying that its display density is 149 PPI.

But when I printed dpi using display metrics its showing as 160 dpi.

how to know the exact dpi of an devices.


回答1:


PPI and DPI is two different things. The important thing to know about when developing Android applications is the DPI.

It can be found like this:

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int dpi = dm.densityDpi;

Android works with general classes of DPI:

  • ldpi = 120
  • mdpi = 160
  • hdpi = 240
  • xhdpi = 320

Take a look here for more information: http://developer.android.com/guide/practices/screens_support.html




回答2:


Adding to Cant0na answer, which is totally correct, in this great post Dianne Hackborn (Google engineer) explains exactly how the dpi works. I think the reading of it is a must for every Android dev. Among other things, she says:

So Android defines a few major buckets of density values that devices can used, called ldpi (approx 120dpi), mdpi (160 dpi), hdpi (240 dpi), and xhdpi (320 dpi). Manufacturers can select the density that is appropriate for their device, as long as it results in a screen that (after scaling for density) is within the minimum allowed screen size of the platform.



来源:https://stackoverflow.com/questions/9224428/10-inch-tablet-with-149-ppi-is-showing-as-160-dpi-in-program

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