What are the standard sizes of android images?


I'm creating my first application on the Android platform and as far as I know one of the downside of this platform is that the devices on the market have different sizes of screens.

I created a project in Eclipse and found that it creates 4 types of folders to add the images, and my question is: How do I know the size of the images for each type of screen? I have an image size of 150x100 and works correctly for the S3 screen, but on other phones with smaller screens it looks quite different. What do I have to do to make everyone agree, regardless of the screen size?

How large are the images for each folder if I have an image for S3 in size 150x100?

asked by anonymous 16.12.2013 / 19:28

3 answers


It is not that there are standard sizes, after all your image can occupy a corner of the screen or even a full screen. However, there are recommendations.

The point is: your layout should be resized according to the size of the user's screen. If you use very large images they will look strange and heavy on small screens. If you use small images, they will become serrated on large screens.

In documentation , the most recent solution is to use size ranges for width, height, or both. This is done by naming directories with a specific pattern. For example:

  • sw600dp : The folder will be used on screens where the height and width are both greater than or equal to 600 pixels .
  • w720dp : The folder will be used on screens where the width is greater than or equal to 720 pixels .
  • h720dp : The folder will be used on screens where the height is greater than and equal to 720 pixels .

You should configure your app to tell Android which resolutions are supported.

For illustration purposes only, you could create folders with 480 , 600 and 720 pixels [1] with an image to display in full screen. The tracks where they would be:

  • 479 : Android uses the res/layout/
  • From 480 to 599 : Android uses the res/layout-w480dp
  • From 600 to 719 : Android uses the res/layout-w600dp
  • As of 720 : Android uses the res/layout-w720dp

The images should be at least the size of the upper limit of the tracks. For example, because the first track is up to 479 pixels, the image must be at least 479 pixels [1] so that it does not need to be magnified and thus deformed.

* Note [1]: Although I used the unit "pixel" in the text above, it was just for the sake of simplifying the text. The unit is dp ( density-independent pixels ).

16.12.2013 / 20:05

I will not give you an extended explanation here, just teach me how to calculate the image sizes for each density, which is the purpose of the question. For a general explanation of density, pixel resolution, etc. refer to the documentation .

The densities are, in order from lowest to highest: ldpi, mdpi, hdpi, xhdpi, xxhdpi and xxxhdpi.

There is a relation of proportion between them (1: 2: 3: 4: 6: 8), which means: an mdpi figure is twice the size of an ldpi (2: 1 ratio), hdpi is triple of a ldpi (3: 1 ratio), etc. Of course, ldpi has the same ldpi size, that is, a ratio of 1: 1.

But this relationship is only useful in the way it is (1: 2: 3: 4: 6: 8) if you take as base the density ldpi, which is the lowest. If you rely on another resolution, you will need to recalculate these values (the ratio between them will be maintained).

For example: taking the case of your Samsung SIII, which has xhdpi density. The ratio ratio for itself is 4: 4 = 1. So take the value 4 as a divisor (second operand of a division). The dividend (first operand) will be the density for which you want to calculate the image size. For example, if you want to calculate for hdpi, the ratio will be 3: 4 = 0.75. That is, the corresponding hdpi image will be 0.75 times (or three quarters) smaller than the xhdpi image. This means that the 150x100 pixels in xhdpi will become 112.5 x 75 pixels (or 112 x 75, as it has to be integers) on a hdpi screen.

The same logic can be applied to obtain the images in the other densities. So:

xxxhdpi = 300x200 px
xxhdpi = 225x150 px
mdpi = 75x50 px
ldpi = 37x25 px
16.12.2013 / 20:15

To help you with your first App and to create images for each density, I automatically recommend using the tool.

Android Asset Studio

03.01.2014 / 20:32