What are the default sizes of android images?

Asked

Viewed 13,164 times

29

I’m creating my first app on the Android platform and as far as I know one of the negatives of this platform is that existing devices on the market have different screen sizes.

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

What size of images for each folder, if I have an image for S3 in size 150x100?

  • It is not the Android platform (based on Linux) that has several screen sizes, but the devices that there use. Usually they are mobile devices and therefore it is common for any platform with target for these devices to have this feature (Windows Phone, Palmos). Nor can it be considered a negative point as this allows for varied devices with different costs and end applications, meeting a wider range of applications.

  • 1

    @Diegocnascimento I think he spoke from the developer’s point of view, referring to the greater complexity to build the application due to the variety of screen sizes he will need to meet.

  • Exactly @Piovezan

  • I have the same doubt. I don’t know if each folder needs to have an image with a specific resolution. If it is set in pixel or dpi.

3 answers

25


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 question is: your layout should be resized according to the size of the user’s screen. If you use very large images they will get weird and heavy on small screens. If you use small images they will become serrated on large screens.

In the documentation Regarding this, the most recent solution pointed out 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[1].
  • w720dp: the folder will be used on screens where the width is greater than or equal to 720 pixels[1].
  • h720dp: the folder will be used on screens where the height is greater and equal to 720 pixels[1].

You must configure your application to inform Android which resolutions supported.

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

  • Up until 479: Android uses the folder res/layout/
  • Of 480 until 599: Android uses the folder res/layout-w480dp
  • Of 600 until 719: Android uses the folder res/layout-w600dp
  • From 720: Android uses the folder res/layout-w720dp

The images should have at least the size of the upper limit of the tracks. For example, as the first track goes up to 479 pixels[1], The image must be at least 479 pixels[1] so that it does not need to be enlarged and thus suffer deformation.

* Note [1]: although I have used the "pixel" drive in the above text, it was only for the purpose of simplifying the text. The drive is dp (Density-Independent pixels).

  • 1

    A correction: in sw600dp for example, dp means Density-Independent pixels, which is different from pixels (px). 600dp is an absolute density value, while pixels indicate a relative density (the corresponding absolute density will depend on the screen size in square centimeters or square inches).

  • @Piovezan Corretíssimo, I did not want to complicate the post with a different unit and forgot to put a note. Thanks.

12

I’m not going to give an extensive explanation here, I’m just going to teach you how to calculate the image sizes for each density, which is the point of the question. For a general explanation of density, pixel resolution, etc. it is recommended to refer to documentation.

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

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

But this relation is only useful as it stands (1:2:3:4:6:8) if you base it on the lowest density ldpi. If you base this 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 of proportion for himself is 4:4 = 1. Therefore take 4 as the 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, since it has to be whole numbers) on an hdpi screen.

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

xxxhdpi = 300x200 px
xxhdpi = 225x150 px
mdpi = 75x50 px
ldpi = 37x25 px

1

To help you in your first App and create the images for each density automatically recommend using the tool .

Android Asset Studio

Browser other questions tagged

You are not signed in. Login or sign up in order to post.