简体   繁体   English

三星 Galaxy S10 的密度 DPI 太小?

[英]Density DPI of Samsung Galaxy S10 too small?

I've been getting device density like this:我一直在获得这样的设备密度:

val wm = getSystemService(Context.WINDOW_SERVICE) as WindowManager
val display = wm.defaultDisplay
val metrics = DisplayMetrics()
display.getMetrics(metrics)
val density = metrics.densityDpi

Then I based some logic on the value of density and constants:然后我根据density和常数的值建立了一些逻辑:

  • DENSITY_XHIGH
  • DENSITY_XXHIGH

I expected S10 to fall under DENSITY_XXHIGH but apparently it's density value is 420 , contrary to S9 which density is 480 .我预计 S10 会落在DENSITY_XXHIGH之下,但显然它的density值为420 ,而 S9 的密度为480

  1. Does that mean that S10 is actually using resources from xhdpi and not xxhdpi folder?这是否意味着 S10 实际上使用的是来自 xhdpi 而不是 xxhdpi 文件夹的资源?
  2. If this value is not reliable what value should I base on my logic for choosing optimal image size before I load int into ImageView ?如果这个值不可靠,在我将 int 加载到ImageView之前,我应该根据我的逻辑选择最佳图像大小的值是什么?

If you want to know what is used, I suggest to create a "whoami" string and place it in values-xhdpi and all other *dpi variants.如果您想知道使用了什么,我建议创建一个“whoami”字符串并将其放置在values-xhdpi和所有其他 *dpi 变体中。

values-xhdpi/whoami.xml值-xhdpi/whoami.xml

<resources>
    <string name="density_bucket" translatable="false">xhdpi</string>
</resources>

If you use that value, you know what the Android system selects from during runtime.如果您使用该值,您就知道 Android 系统在运行时会选择什么。

As this is a nice way for "debugging" your question to a specific device, you can also adopt to this.由于这是将您的问题“调试”到特定设备的好方法,因此您也可以采用此方法。 In my case this value is used to request the right image sizes from an asset backend.在我的情况下,此值用于从资产后端请求正确的图像大小。

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

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