dp,dip,dpi,ppi,像素和英寸之间有何关系? [英] How do dp, dip, dpi, ppi, pixels and inches relate?

查看:186
本文介绍了dp,dip,dpi,ppi,像素和英寸之间有何关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 dp,dip,px,sp测量,但我仍然对dp/dpi与ppi,px与px有疑问.我无法比较它们……最大的是一英寸吗?

I was reading dp, dip, px, sp measurements, but I still have some questions about dp/dpi vs ppi vs px vs inch. I am not able to compare them... is an inch the largest?

他们说160 dpi表示每1英寸160像素.这是否意味着1英寸包含160个像素?

They say 160 dpi means 160 pixels per one inch. Does that mean 1 inch contains 160 pixels?

他们还说160 dpi屏幕上的1像素= 1 dp.那是否意味着1像素和1 dp相等?

They also say 1 pixel on a 160 dpi screen = 1 dp. Does that mean 1 pixel and 1 dp are equal?

最后,为什么我们要使用dp而不是px?我了解这是理想的选择,但是为什么?

And lastly, why should we use dp instead of px? I understand that it is ideal, but why?

推荐答案

您应该(几乎)始终使用灵活的尺寸调整单位,例如dp,它是与密度无关的像素,因为不一定要在一台设备上使用300px屏幕空间与300px在另一个屏幕上的空间相同.最大的实际影响是,在密度不同于设计目标的设备上,布局看起来会大不相同.

You should (almost) always use flexible sizing units, like dp, which is Density-Independent Pixels, because 300px on one device is not necessarily the same amount of screen real estate as 300px on another. The biggest practical implication is that your layout would look significantly different on devices with a different density than the one your design targeted.

  • dpdip表示与密度无关的像素
  • dpippi表示每英寸的点(或像素)
  • inch是与实际屏幕尺寸相关的物理测量结果
  • px表示像素-像素会根据密度填充任意数量的屏幕区域.
  • dp or dip means Density-independent Pixels
  • dpi or ppi means Dots (or Pixels) Per Inch
  • inch is a physical measurement connected to actual screen size
  • px means Pixels — a pixel fills an arbitrary amount of screen area depending on density.

例如,在160dpi屏幕上1dp == 1px == 1/160in,但是在240dpi屏幕上1dp == 1.5px.所以不,1dp != 1px. 1dp == 1px时,只有一种情况,并且在160dpi屏幕上.诸如英寸之类的物理测量单位永远不要 成为设计的一部分,也就是说,除非要制作标尺.

For example, on a 160dpi screen, 1dp == 1px == 1/160in, but on a 240dpi screen, 1dp == 1.5px. So no, 1dp != 1px. There is exactly one case when 1dp == 1px, and that's on a 160dpi screen. Physical measurement units like inches should never be part of your design—that is, unless you're making a ruler.

用于确定1dp的像素数的简单公式是px = dp * (dpi / 160).

A simple formula for determining how many pixels 1dp works out to is px = dp * (dpi / 160).

这篇关于dp,dip,dpi,ppi,像素和英寸之间有何关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆