Android screen density dpi vs ppi

穿精又带淫゛_ 提交于 2019-12-23 17:49:25

问题


According to the android documentation, density should be in dpi (dots per inch) and all layout measurement should be in dp.

and using a simple formula android can map dp to actual pixels.

px = dp * (dpi / 160), 
160dpi ~ medium density screen which is the baseline

So why not just use ppi (pixels per inch) to describe screen density ?


回答1:


There is a lot of documentation about this issue, but I think this part is relevant for your question:

Supporting Multiple Screens

Density independence

Your application achieves "density independence" when it preserves the physical size (from the user's point of view) of user interface elements when displayed on screens with different densities.

Maintaining density independence is important because, without it, a UI element (such as a button) appears physically larger on a low-density screen and smaller on a high-density screen. Such density-related size changes can cause problems in your application layout and usability. Figures 2 and 3 show the difference between an application when it does not provide density independence and when it does, respectively.




回答2:


From what I've read it is a design based distinction; the developers shouldn't worry about the individual screens they are deploying to, and should use dp within the application to make it as portable as possible across the different android devices.

For designers of assets the display size and sharpness of image are more important, and the dpi distinction is the one that matters to them.

For more information check out this article/e-book written by a google engineer:

http://sebastien-gabriel.com/designers-guide-to-dpi/

In particular check out the section "The PPI Configuration". Quote from the article:

Anything non-print uses pixel sizes regardless of the initial PPI configuration... PPI configuration in software is a printing legacy. If you design only for the web, PPI won't have any influence on the size of your bitmap.



来源:https://stackoverflow.com/questions/32549719/android-screen-density-dpi-vs-ppi

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