是基于屏幕的物理尺寸DP? (一英寸DP = 1/160) [英] Is dp based on the physical size of the screen? (dp =1/160 of an inch)

查看:1149
本文介绍了是基于屏幕的物理尺寸DP? (一英寸DP = 1/160)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是定义是否正确?

DP密度无关的像素 - 1/160的基于屏幕的物理尺寸的英寸

我找到了相互矛盾的信息:

I have found conflicting information:

官方文档假定的缩放比例的方程PX = DP *(DPI / 160)。 此外这里(3:02)罗马Nurik说:缩放比例

The official documentation assumes scaled proportionally in equation "px = dp * (dpi / 160)". Also here (3:02) Roman Nurik says "scaled proportionally"

但在官方文档:

像素的像素 - 对应于屏幕上实际像素。以英寸来算 -   根据屏幕的物理尺寸。毫米毫米 - 基于   屏幕的物理尺寸。 PT点 - 1/72英寸的基础上   屏幕的物理尺寸。 DP密度无关的像素 - 一个   是基于屏幕的物理密度抽象单元。   这些单位是相对于160 dpi(每英寸点数)的屏幕,在其上   1DP约等于1像素。较高密度屏幕上运行时,   用于绘制1DP像素的数量按比例增加的一个因素   适合屏幕的DPI。同样地,在一个较低的密度时   屏幕上,用于1DP像素的数量按比例缩小。的比率   DP到像素将与屏幕密度变化,的但不一定   正比例

px Pixels - corresponds to actual pixels on the screen. in Inches - based on the physical size of the screen. mm Millimeters - based on the physical size of the screen. pt Points - 1/72 of an inch based on the physical size of the screen. dp Density-independent Pixels - An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi (dots per inch) screen, on which 1dp is roughly equal to 1px. When running on a higher density screen, the number of pixels used to draw 1dp is scaled up by a factor appropriate for the screen's dpi. Likewise, when on a lower density screen, the number of pixels used for 1dp is scaled down. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion.

如果我的定义是正确的,为什么要引入一个新的物理尺寸的措施,如果我们已经有知名毫米,和Pt?

If my definition is correct, Why introduce a new physical size measure if we already have the well-known mm, in and pt?

推荐答案

样的计量单位毫米是因为 DP 办法减少混乱的措施同现实世界中观察到的长度。这会产生误导,另一方面,因为 DP 不是一个绝对的定义的单位。

A measurement unit like mm or in would be way less confusing since dp measures the same real world observed length. It would be misleading on the other hand since dp is not an absolutely defined unit.

使用屏幕像素密度桶意味着 DP 是一个有点模糊 - 但它会留在合理的(+/- 20%?)精度。现实世界中的显示器通常是不完全如160dpi它们可以是173.4 dpi与仍然被分类为160dpi。开展了从 DP 转换为像素在屏幕上的数学是基于这些水桶做的,这意味着,精度 DP 取决于如何准确设备的屏幕满足它的分类。

The use of screen density buckets means that dp is a bit fuzzy - but it will stay within reasonable (+/-20% ?) accuracy. Real world displays are usually not exactly e.g. 160dpi they can be 173.4 dpi and still be classified as 160dpi. The math carried out to convert from dp to pixels on the screen is done based on these buckets and that means that the accuracy of dp depends on how accurately your device screen meets it's classification.

但要清除您的疑问:160dp始终为1(模糊)英寸,无论你在你的手握住了什么设备。更容易想到:50dp = 1(小)手指宽

But to clear your doubt: 160dp is always 1 (fuzzy) inch regardless of what device you hold in your hand. Easier to think of: 50dp = 1 (small) finger wide.

PX像素,另一方面是实际的像素。全高清显示器具有其中的1920×1080,但该单位没有对屏幕大小或有多大这样的像素会出现在用户面前说。 DP 是一个不同的单位,应该从来没有被称为像素在我看来。

px Pixels on the other hand are actual pixels. A full HD display has 1920x1080 of them but that unit says nothing about the screen size or how big such a pixel will appear to the user. dp or dip is a different unit and should have never been called "pixel" in my opinion.

这篇关于是基于屏幕的物理尺寸DP? (一英寸DP = 1/160)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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