简体   繁体   中英

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. For the Nexus 10 this image should be 2560x1600 and placed at the xhdpi folder.

It's nonsense to place an image bigger in the xhpdi folder than an image placed at the xxhdpi folder. 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:

The answer of prijupaul is good, but I don't have any Nexus 10 or Galaxy S4 to test. I discovered the resolution trying to create AVDs for both, in the device configuration creation it says what configuration it one will be.

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).

The S4 has a lower resolution but can have a higher density because it screen is smaller.

I think it is quite well explained in the documentation (developer.android.com). Check that for more details.

You should then use another qualifier than xhdpi if resolution does really matter. You can use for example drawable-sw720dp (targets 10" tablets).

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? 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 '. Galaxy s4 has 441 ppi but Nexus 10 has 300 ppi.

Are you sure image for nexus10 should be in xhdpi folder? Nexus10 has 300ppi,which is different to dip. Visit Android XXHDPI resources

It should be like this, s4:xhdpi nexus10:xxhdpi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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