简体   繁体   English

什么是Android DPI

[英]what's android DPI

I have 2 questions about the "DPI" term. 我对“ DPI”一词有2个问题。
1st, i googled this term, someone said that it means dots per inch. 首先,我用谷歌搜索这个词,有人说这表示每英寸点数。 and we can use follow formula to canculate the screen dpi: dpi = radical(screen_width_pixel^2+screen_height_pixel^2)/screen_inchs 我们可以使用以下公式来计算屏幕dpi: dpi =自由基(screen_width_pixel ^ 2 + screen_height_pixel ^ 2)/ screen_inchs
Now, i have an android tv, i found that my tv resolution is 1920*1080, and the dpi is 240, the tv size is 50 inch. 现在,我有一个Android电视,我发现电视分辨率为1920 * 1080,而dpi为240,电视尺寸为50英寸。 But if i use above formula to calculate the dpi, i will get the dpi value is 40, i don't know why? 但是,如果我使用上述公式计算dpi,我将得到dpi值为40,我不知道为什么? is above formula ppi formula? 以上公式是ppi公式吗?
2nd, i found that the dpi value is in the build.prop->ro.sf.lcd_density=240 , i don't know why the manfacturer set this value, in other words, what is this value based on, why not setting 320 or other values? 2,我发现dpi值在build.prop-> ro.sf.lcd_density = 240中 ,我不知道制造商为什么要设置此值,换句话说,此值是基于什么,为什么不设置320或其他值? They user above farmula to get the value and set it? 他们在农法上方使用以获得值并进行设置吗?
Thanks a lot! 非常感谢!

I have been researching answer to your question for last one day, and reached some conclusions - 1. 我过去一天一直在研究您的问题的答案,并得出了一些结论-1。

  1. PPI is pixels per inch, purely mathematical. PPI是每英寸像素,纯粹是数学上的。 ie - it calculate number of pixels per inch. 即-它计算每英寸的像素数。
  2. DP - Device Independent Pixels AKA dots -> ie android system defines a virtual pixel so that it could compare devices with different pixel densities. DP-设备无关像素AKA ->即android系统定义了一个虚拟像素,以便可以比较具有不同像素密度的设备。 You know baseline is 160 DPi (160 dots per inch), so any MDPI device has a virtual grid which contains 160 DP per inch, while a device which is HDPI has same grid but it will contain 240 DP per inch. 您知道基线是160 DPi(每英寸160点),因此任何MDPI设备都有一个虚拟网格,每英寸包含160 DP,而HDPI设备具有相同的网格,但每英寸包含240 DP。 (Note that number of pixels one dot/Device independent Pixel may contain varies, depending on the size of device.) (请注意,一个点/与设备无关的像素可能包含的像素数会有所不同,具体取决于设备的大小。)
  3. here comes your answers- a) DPi is system defined, all you can calculate is number of DP in one inch, which in your case sums up to - 1920*160/240 =1280 DPs in height, 1080*160/240 = 720 DPs in width), what you calculated is PPi. 这是您的答案-a)DPi是系统定义的,您所能计算的是一英寸中的DP数量,在您的情况下,总计为-1920 * 160/240 = 1280 DPs高度,1080 * 160/240 = 720 DP宽度),则您计算出的是PPi。 b) manufacturer set it so that you could know how much you need to resize your image. b)制造商对其进行设置,以便您知道调整图像大小需要多少。 Suppose an image which is of certain size in 160DPi, then to make this image look same size, you need to double the size of the image on 320DPi screen. 假设某个图像在160DPi中具有一定的大小,那么要使该图像看起来相同,您需要在320DPi屏幕上将该图像的大小加倍。

Note - I tried on my part to make you understand, if you find any problem understanding my answer, Please comment, would be happy to assist. 注意-我已尽力让您理解,如果您发现理解我的答案有任何问题,请发表评论,我们将很乐意为您提供帮助。

Reference # 1 参考编号1

Try this information Iuser lastly to develop and android studio screens 最后尝试Iuser的此信息以开发和android studio屏幕

ldpi (low) ~ 120dpi
mdpi (medium) ~ 160dpi
hdpi (high) ~ 240dpi
xhdpi (extra-high) ~ 320dpi
xxhdpi (extra-extra-high) ~ 480dpi
xxxhdpi (extra-extra-extra-high) ~ 640dpi

- -

res/values/dimens.xml(default)
res/values-ldpi/dimens.xml   (240x320 and nearer resolution)
res/values-mdpi/dimens.xml   (320x480 and nearer resolution)
res/values-hdpi/dimens.xml   (480x800, 540x960 and nearer resolution)
res/values-xhdpi/dimens.xml  (720x1280 - Samsung S3, Micromax Canvas HD, etc) 
res/values-xxhdpi/dimens.xml (1080x1920 - Samsung S4, HTC one, etc)
res/values-large/dimens.xml  (480x800)

- -

res/values-large-mdpi/dimens.xml (600x1024)
res/values-sw600dp/dimens.xml  (600x1024)
res/values-sw720dp/dimens.xml  (800x1280)
res/values-xlarge-xhdpi/dimens.xml (2560x1600 - Nexus 10")
res/values-large-xhdpi/dimens.xml  (1200x1920 - Nexus 7"(latest))

w600 says if width of current orientation is nearby 600 w600表示当前方向的宽度是否在600附近

sq600 says if smallest with of device is nearby 600 sq600表示设备的最小搭配是否在600附近

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM