Introduction to mipmap drawables in Android
Android introduced mipmap drawables for providing more flexibility to design the launcher icons. mipmap first introduced in Android Jelly Beans 4.3. If you are building different versions of your app for different densities, you should know about the mipmap resource directory. This is exactly like normal drawable folder resources, except it does not participate in density stripping while resource optimisation when creating different target apks.
We put our mipmap drawables in mipmap/ directory under res/ folder.
Why we should use mipmaps for app launcher icons?
Devices have different resolutions so the launcher app show the icons on different resolutions. Resource optimisation techniques sometimes removes resources for unused screen densities and when the launcher app has to upscale a lower-resolution icon for display it might look blurred. To avoid this issues, applications should use the mipmap drawable folders for app launcher icons. The Android system never strips this resource, and ensures that launcher apps can pick icons with the best resolution for display.
It makes sure launcher apps show a high-resolution icon for your app by moving all densities of your launcher icons to density-specific res/mipmap/ folders (for example res/mipmap-mdpi/ and res/mipmap-xxxhdpi/). App uses mipmap/ folders instead of the drawable/ folders for launcher icons. For xxhpdi launcher icons, be sure to add the higher resolution xxxhdpi versions of the icons to enhance the visual experience of the icons on higher resolution devices.
Manifest changes
When we place our launcher icons in the mipmap-[density] folders, we change the launcher icon references in the AndroidManifest.xml file to reference the mipmap/ location. Following code snippet shows the manifest file referencing the ic_launcher icon to the mipmap/ folder.
Nexus 6 device example
The Nexus 6 has screen display at a resolution of 2560 x 1440. This translates to ~ 730 x 410 dp. It has a quantized density of 560 dpi, which falls in between the xxhdpi and xxxhdpi. For the Nexus 6, the platform will scale down xxxhdpi assets, but if those aren’t available, then it will scale up xxhdpi assets which might look blurred due to scaling up. Provide at least an xxxhdpi app icon so that devices can display large app icons on the launcher by scaling it down without showing fuzziness. An xxxhdpi app icon can be used on the launcher for an xxhdpi device.
Side effect
Adding xxxhdpi versions will provide a sharper visual experience on the Nexus 6, but it will also increase your apk size.
Thanks for reading!
Happy coding!