[英]finding a proper dp that same size in all devices
As you know if you put dimensions and size in dp it will almost same in all devices. 如您所知,如果将尺寸和尺寸放在dp中 ,它将在所有设备中几乎相同。 I say almost because of bucket range. 我说几乎是因为铲斗范围。 for example in hdpi that presnets with 240dpi a device with 200dpi and 279dpi all use hdpi resource and dimens folder and same size in pixel : 例如在HDPI与240dpi与200dpi的和279dpi所有使用hdpi资源的设备和presnets梦诗文件夹和相同的尺寸中的像素 :
px = dp * (dpi/160) px = dp *(dpi / 160)
so for example an object with 300dp size will be (dp/dpi=inch) 300/200 = 1.5 inch in first device (200dpi) and in another device it will be 300/279=1.07 inch. 例如,具有300dp尺寸的物体在第一装置(200dpi)中将是(dp / dpi =英寸)300/200 = 1.5英寸,而在另一装置中它将是300/279 = 1.07英寸。 (279dpi device) so as you see there is too much difference between high and end of range hdpi and your UI not just same in inch. (279dpi设备)因此,您看到高范围和最终范围hdpi之间存在太大差异,并且您的UI不仅仅是英寸相同。
Ok I found best solution for solving this problem is divide bucket to more specific with sw and change dp size in dimens.xml
for each bucket range. 好的,我发现解决这个问题的最佳解决方案是使用sw来划分桶,并在每个桶范围的dimens.xml
更改dp大小。 but I do not know how to divide bucket and second how to create values for them! 但我不知道如何划分桶和第二个如何为他们创造价值!
problem is what is the proper folder range for this? 问题是这个适当的文件夹范围是什么? what is the best practice for divide sw sizes for achieving this. 为达到这个目的,划分sw尺寸的最佳做法是什么。 (sw160, sw320, sw480 or what?) and how to add value for dimensions? (sw160,sw320,sw480还是什么?)以及如何为尺寸增加价值?
UPDATE UPDATE
some friends say that why you won't use in instead of dp and this is my answer: 有些朋友说为什么你不会用而不是dp,这是我的答案:
i had also similar requirement which i raised at this link Equal number of horizontal cards /items in all devices . 我也有类似的要求,我在这个链接提出了所有设备中相等数量的横向卡/项目 。 Play store app is showing the same way in all the devices of different dpi's. Play商店应用程序在所有不同dpi的设备中显示相同的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.