Image Size (Drawable-Hdpi/Ldpi/Mdpi/Xhdpi)

Sizes for drawable: LDPI, MDPI, HDPI, XHDPI, XXHDPI, XXXHDPI?

Inside Android Studio, if you right click on the res folder, you can select New > Image Asset which will create properly sized drawables for those dpi bucket folders.

Optionally, you can also use a website like this one: http://romannurik.github.io/AndroidAssetStudio/index.html

You can also programmatically change width/height, but this is heavily discouraged due to how disgusting a smaller image looks when it's stretched large. Only use this programmatic solution if you use vector images.

Image resolution for mdpi, hdpi, xhdpi and xxhdpi

Please read the Android Documentation regarding screen sizes.

From a base image size, there is a 3:4:6:8:12:16 scaling ratio in drawable size by DPI.

LDPI - 0.75x
MDPI - Original size // means 1.0x here
HDPI - 1.5x
XHDPI - 2.0x
XXHDPI - 3x
XXXHDPI - 4.0x

For example, 100x100px image on a MDPI will be the same size of a 200x200px on a XHDPI screen.

Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?

I was using "Android Asset Studio". Now I am using IconKitchen, the successor to the Android Asset Studio, and a great new way to make highly customizable app icons for Android, iOS, web, Windows, Linux and Mac.

What's differences between 'drawable' folder and 'drawable-hdpi-ldpi-mdpi-xhdpi' folders?

res/drawable/ is equivalent to res/drawable-mdpi/. The suffix-less name is there for backwards compatibility, before the densities were added in Android 1.5 or thereabouts.

is enough to create suitable image size rate for all devices?

If you do not mind Android scaling your images up and down for other densities, yes. Usually, the quality will degrade the further the density is from the starting point (in this case, -mdpi.

Should I create image size rate for each folder(hdpi, mdpi, ldpi, xhdpi) ?

That depends on the image and the results of the automatic scaling. Many developers will ship a couple of densities, but not all of them, and tending to aim towards higher densities (e.g., -xhdpi). But, you are welcome to do what you want, so long as you feel that your users will be comfortable with the image quality that you deliver to them.

scale images for ldpi mdpi hdpi and xhdpi

Actually, you should not to place THE SAME images to all folders -ldpi, -mdpi, -hdpi.

Lets imagine, you want to support xxhdpi devices. You create image for xxhdpi (for example 1Mb) and put it to all folders.
And what will you get on a ldpi device? Image will be scaled. Quality of image on the screen will be horrible.
And another thing: if you want to have 100 images on a screen at the same time, each by 2-5Mb, and you create all of this images for xxhdpi devices, then you can get OutOfMemoryError on ldpi device.

So, the best practice is NOT to put the same images to all the folders.
If you have some resolution independent images, then you can put them into drawable folder (without postfix). But you should NOT put the same images to ldpi and xxhdpi folders.

So answers with resizing are terrible.

Look at this article

At "Alternative drawables" paragraph.
On this image

Sample Image

you can see that for xhdpi device you should have image 2 times larger than for mdpi.
And so on.

Hope it helps



Related Topics



Leave a reply



Submit