简体   繁体   English

在所有设备中找到相同大小的正确dp

[英]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与240dpi200dpi的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,这是我的答案:

  1. Android get inch with the same formula (screen Resolution / dpi = inch) so the problem is same and it's is not exact in all devices. Android使用相同的公式获得英寸(屏幕分辨率/ dpi =英寸)所以问题是相同的并且在所有设备中并不完全相同。
  2. Android told that using inch and mm and cm is not recomended. Android告诉我不建议使用英寸和毫米和厘米。

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.

相关问题 尽管我使用了 dp,但为什么我的应用程序在不同设备上看起来不一样。 dp 不应该在不同尺寸的设备中显示相同吗? - why my app doesn't look like same in different devices although I used dp. Isn't dp should be shown same in different size devices? 具有相同dp Widht和dp Height但密度不同的设备的字体大小 - Fontsize for devices with same dp Widht and dp Height but different densities 所有设备的弯曲背景尺寸相同 - Same size curved background for all devices 在所有android设备中实现相同的字体大小 - achieving same font size in all android devices 在所有设备中显示相同尺寸的按钮 - show same size button in all devices Android按钮大小在不同设备上更改(宽度设置为dp) - Android button size changes at different devices (width is set to dp) Android如何评估视图大小以在所有设备中保持相同比例 - Android how to evaluate view size to keep same proportion in all devices Android将多边形从地图保存为所有设备的相同大小的位图 - Android save polygon from map as bitmap same size for all devices Android-无法在所有设备上绘制相同大小的正方形 - Android - Can't draw same size square on all devices Android:可以在布局上使用DP并使其在所有设备上看起来一样吗? - Android: Possible to use DP on a layout and make it look the same across devices?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM