简体   繁体   English

适用于Samsung Galaxy S4和Nexus 10的Android可绘制

[英]Android drawable for Samsung Galaxy S4 and Nexus 10

I have an image that is the background of one activity in my app. 我的图片是我的应用中一项活动的背景。

For the Samsung Galaxy S4 this image should be 1920x1080 and placed at the xxhdpi folder. 对于Samsung Galaxy S4,此图像应为1920x1080,并放置在xxhdpi文件夹中。 For the Nexus 10 this image should be 2560x1600 and placed at the xhdpi folder. 对于Nexus 10,此图片应为2560x1600,并放在xhdpi文件夹中。

It's nonsense to place an image bigger in the xhpdi folder than an image placed at the xxhdpi folder. 在xhpdi文件夹中放置比在xxhdpi文件夹中放置的图像更大的图像是没有意义的。 And because that I believe that I misunderstood something. 并且因为那我相信我误解了。

Can someone explain what I misunderstood? 有人可以解释我的误解吗?

--edit-- - 编辑 -

For all the answer questioning if the nexus10 is really xhdpi and the S4 xxhdpi: 对于所有询问是否nexus10确实是xhdpi和S4 xxhdpi的答案:

The answer of prijupaul is good, but I don't have any Nexus 10 or Galaxy S4 to test. prijupaul的答案很好,但我没有要测试的Nexus 10或Galaxy S4。 I discovered the resolution trying to create AVDs for both, in the device configuration creation it says what configuration it one will be. 我发现了尝试为两者创建AVD的解决方案,在设备配置创建过程中,它说明了它将是哪种配置。

The resource classes 'hdpi', 'xhdpi' and 'xxhdpi' have nothing to do with resolution (width and height in plain pixels) but everything to do with density (number of pixels per inch of screen). 资源类“ hdpi”,“ xhdpi”和“ xxhdpi”与分辨率(以像素为单位的宽度和高度)无关,而与密度(每英寸屏幕的像素数)有关。

The S4 has a lower resolution but can have a higher density because it screen is smaller. S4的分辨率较低,但由于屏幕较小,因此可以具有较高的密度。

I think it is quite well explained in the documentation (developer.android.com). 我认为文档(developer.android.com)中对此进行了很好的解释。 Check that for more details. 检查以获取更多详细信息。

You should then use another qualifier than xhdpi if resolution does really matter. 如果分辨率确实很重要,则应使用xhdpi以外的其他限定符。 You can use for example drawable-sw720dp (targets 10" tablets). 您可以使用例如drawable-sw720dp(目标为10“平板电脑)。

My personal opinion though is that you should just have a version for each aspect ratio in the biggest size. 不过我个人的观点是,您应该只为每个长宽比提供一个最大尺寸的版本。 Then compute that aspect ratio at runtime and pick the best image from assets. 然后在运行时计算该纵横比,并从资产中选择最佳图像。

Isnt S4 is xhdpi? S4不是xhdpi吗? Did you verify using 您是否使用过验证

DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int density = dm.densityDpi;
switch(density)
{
 case DisplayMetrics.DENSITY_LOW:
  Toast.makeText(context, "ldpi", Toast.LENGTH_SHORT).show();
  break;
 case DisplayMetrics.DENSITY_MEDIUM:
  Toast.makeText(context, "mdpi", Toast.LENGTH_SHORT).show();
  break;
 case DisplayMetrics.DENSITY_HIGH:
  Toast.makeText(context, "hdpi", Toast.LENGTH_SHORT).show();
  break;
 case DisplayMetrics.DENSITY_XHIGH:
  Toast.makeText(context, "xhdpi", Toast.LENGTH_SHORT).show();
  break;
 case DisplayMetrics.DENSITY_XXHIGH:
  Toast.makeText(context, "xxhdpi", Toast.LENGTH_SHORT).show();
  break;
}

This does not answer the question. 这不能回答问题。 But, This could will be useful to double check it again. 但是,再次进行仔细检查可能会很有用。

I think it's about to ' PPI '. 我认为这将是“ PPI ”。 Galaxy s4 has 441 ppi but Nexus 10 has 300 ppi. Galaxy s4为441 ppi,而Nexus 10为300 ppi。

Are you sure image for nexus10 should be in xhdpi folder? Nexus10 has 300ppi,which is different to dip. 您确定nexus10的图片应该在xhdpi文件夹中吗?Nexus10的分辨率为300ppi,这与浸渍不同。 Visit Android XXHDPI resources 访问Android XXHDPI资源

It should be like this, s4:xhdpi nexus10:xxhdpi 应该是这样,s4:xhdpi nexus10:xxhdpi

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

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