微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android屏幕密度dpi与PPI

根据android文档,密度应以dpi(每英寸的点数)为单位,所有布局尺寸应以dp为单位.

并使用一个简单的公式android可以将dp映射到实际像素.

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

那么,为什么不只使用ppi(每英寸像素)来描述屏幕密度呢?

解决方法:

关于此问题有很多文档,但是我认为这部分与您的问题有关:

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.

enter image description here

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐