androidandroid-layoutandroid-drawableandroid-resolution

how to use drawable to compatible with all screen sizes (idpi, mdpi, hdpi, xhdpi, xxhdpi)


Hello I am new in android programing so I want to know:

How to use drawable to compatible with all screen sizes (idpi, mdpi, hdpi, xhdpi, xxhdpi)

Actually I am confused about drawable screen sizes compatibility with all screen sizes

so I want to know that:

If I want my app to compatible with all screen size do I need to put images in every drawable folder

for example: background image

or I can use a single same image for all screen sizes.


Solution

  • You do not need to create an image in every possible drawable folder. It's enough to provide one image only and put it into drawable folder. This image will be scaled automatically, depending on your usage.

    This will not provide good quality on all screens though and may be more expensive to compute (scale). It is recommended that you can provide separate images for different screen densities (e.g. drawable-mdpi, drawable-hdpi, etc.) and the idea is that they should have different resolutions matching the screen densities.