Quick note: If you are a designer than share this link with your Android engineers and never again bother with slicing assets for different device density screens.
In Android app development, it’s a good practice to support multiple screens. And even if you’re making an app only for smartphones and only for a portrait mode, you have to deal with different screen densities. So, you open your design file in Photoshop or Sketch, and start extracting assets, adding all those multipliers for mdpi, hdpi, xhdpi, xxhdpi and now also xxxhdpi (!) device density.
But I will share with you a few hacks on how to make this easier!
Here is what you need:
- Android Studio 1.4
- Android Gradle plugin 1.5.0
Open your design files and export your assets in .svg format. Now in Android Studio right click on res folder → new → Vector Asset. This will open Vector Asset Studio and you can select one of the default material icons, in case you need one, or you can import your svg file.
A hint: if Android Vector Studio says there is an error importing your file, no worries, there is a plenty of online resources to help you with vector drawables. Or you can open your svg file and copy pathData into your vector drawable.
That’s it! Now you have only one resource for each asset.
In reality though, vector drawables are supported only on Android 5.0, api level 21, so what happens is that gradle plugin renders all that drawables for different densities to package them into resulting .apk file to be displayed on older versions.
What hacks for working with drawables and supporting multiple screens do you know? Let us know in the comments below.