[英]Why does my android emulator, and my android phone give me different results for a devices density and DPI?
On my Lg G stylo h634, it has a resolution of (720*1280) w/ a size of 5.7 inches and a real PPI of 258. With this information this phone should have: 在我的Lg G stylo h634上,其分辨率为(720 * 1280),尺寸为5.7英寸,实际PPI为258。使用此信息,此手机应该具有:
DP width: 240
DP height: 240
Density: 1.5
Density PPI: 240
However when i run my test on this real device it's giving me: 但是,当我在此真实设备上运行测试时,它给了我:
DP width: 257
DP height: 258
Density: 2.0
Density PPI: 320
Now when i run an emulated version of my phone with the same specs, the first metrics are given (density: 1.5, PPI: 240, etc) which are the proper metrics. 现在,当我以相同规格运行手机的仿真版本时,会给出第一个指标(密度:1.5,PPI:240等),它们是适当的指标。 I'm not sure why this is happening, but can anybody explain why an emulated version is more accurate than the real device?
我不确定为什么会这样,但是有人可以解释为什么仿真版本比真实设备更准确吗?
Its not always about the DPI and PPI. 它并不总是与DPI和PPI有关。 The real phone comes with variety of hardware components.
真正的电话带有各种硬件组件。 although the specs of real phone and emulator is same but real phone renders things differently also it scale things differently.
尽管真实电话和仿真器的规格相同,但真实电话呈现的内容不同,缩放比例也不同。 My advice is try to run you app.
我的建议是尝试运行您的应用。 on few more physical devices and compare to emulator one of equivalent specs result would not differ much.
在更多的物理设备上,与仿真器相比,等效规格之一的结果相差不大。
but can anybody explain why an emulated version is more accurate than the real device?
但是有人可以解释为什么仿真版本比真实设备更准确吗?
It's not. 不是。 The device is what the device is.
设备就是设备。
On DisplayMetrics
, xdpi
and ydpi
are the actual physical density values. 在
DisplayMetrics
, xdpi
和ydpi
是实际的物理密度值。 For example, the documentation for xdpi
has : 例如,
xdpi
的文档包括 :
The exact physical pixels per inch of the screen in the X dimension.
X尺寸屏幕每英寸的确切物理像素。
In your question, you state that the device has "a real PPI of 258". 在您的问题中,您声明该设备的“真实PPI为258”。 That fits the values that you are getting from
DisplayMetrics
, bearing in mind that pixels are rarely square, so the xdpi
and ydpi
values are rarely exactly equal. 请记住,像素很少是正方形的,因此这与您从
DisplayMetrics
获取的值xdpi
,因此xdpi
和ydpi
值很少完全相等。
The value for density
is based on a manufacturer setting ( ro.sf.lcd_density
in /system/build.prop
, I think). density
值基于制造商设置(我认为ro.sf.lcd_density
中的/system/build.prop
)。 Why LG decided to go with xhdpi
instead of hdpi
, I cannot say. 我不能说为什么LG决定使用
xhdpi
而不是hdpi
。 If I had to guess, they felt that existing apps looked better on the device with that logical density. 如果我不得不猜测,他们会觉得现有应用在具有这种逻辑密度的设备上看起来更好。 The emulator will use its own algorithm.
仿真器将使用其自己的算法。 Another manufacturer with a similar screen might choose
hdpi
(what the emulator chose). 另一个具有类似屏幕的制造商可能会选择
hdpi
(模拟器选择的内容)。
The value for densityDpi
is driven directly from density
. densityDpi
的值直接由density
驱动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.