Is there a way to create xxhdpi, xhdpi, hdpi, mdpi and ldpi drawables from a large scale image?
Option #1: Just ship the -xxhdpi
drawables and let Android downsample them for you at runtime (downside: will only work on fairly recent devices, where -xxhdpi
is known).
Option #2: Use Android Asset Studio to downsample them for you.
Option #3: Automate the process within a graphics editor, per ssantos' answer.
Option #4: Script yourself a solution, using something like ImageMagick.
Option #5: Use image baker
Update:
The plugin previously mentioned has been abandoned, but it apparently has an up-to-date fork here.
Old Answer:
I use the Android Studio plugin named Android Drawable Importer
:
To use it after installed, right click your res/drawable folder and select New > Batch Drawable Import
:
Then select your image via the +
button and set the Resolution to be xxhdpi (or whatever the resolution of your source image is).
Update:
The old way of installing the plugin doesn't work anymore but a fork of original plugin is still functional here. You can still follow this answer after installing the plugin manually.
If you want quick and easy way visit https://www.img-bak.in/ or https://appicon.co/ they work with iOS as well.
I will try to explain the process in step wise basis, so that it will be simple to understand to anyone.
1. Install the plugin manually as provided in the ReadME
2. Restart android studio
3. As you can see in the following screencap, there is only one drawable here
4. Now right-click on the drawable folder and navigate to New>Batch Drawable Import