dp、dip、dpi、ppi、像素和英寸有什么关系? [英] How do dp, dip, dpi, ppi, pixels and inches relate?

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

问题描述

我正在阅读 dp、dip、px、sp 测量,但我仍然有一些关于 dp/dpi vs ppi vs px vs inch 的问题.我无法比较它们……一英寸是最大的吗?

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 意味着每英寸 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,它是 Density-Independent Pixels,因为 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天全站免登陆