{"id":31846,"date":"2016-01-28T01:14:54","date_gmt":"2016-01-27T19:44:54","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=31846"},"modified":"2016-02-08T11:47:25","modified_gmt":"2016-02-08T06:17:25","slug":"introduction-to-mipmap-drawables-in-android","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/introduction-to-mipmap-drawables-in-android\/","title":{"rendered":"Introduction to mipmap drawables in Android"},"content":{"rendered":"<p>Android introduced mipmap drawables for providing more flexibility to design the launcher icons. mipmap first introduced in Android Jelly Beans 4.3. \u00a0If you are building different versions of your app for different densities, you should know about the mipmap resource directory.\u00a0 This is exactly like normal drawable folder resources, except it does not participate in density stripping while resource optimisation when creating different target apks.<\/p>\n<p>We put our mipmap drawables in mipmap\/ directory under res\/\u00a0folder.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-31850\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/01\/mipmap1.png\" alt=\"mipmap1\" width=\"624\" height=\"185\" \/><\/p>\n<h2><strong>Why we should use mipmaps for app launcher icons?<\/strong><\/h2>\n<p>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 <a title=\"android application development services\" href=\"http:\/\/www.tothenew.com\/mobile-android-application-development-services\">Android system<\/a> never\u00a0strips this resource, and ensures that launcher apps can pick icons with the best resolution for display.<\/p>\n<p class=\"p1\"><span style=\"color: #000000;\">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\u00a0uses\u00a0mipmap\/ folders instead of\u00a0the 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.<\/span><\/p>\n<h3 class=\"p1\"><span class=\"s1\" style=\"color: #000000;\">Manifest changes<\/span><\/h3>\n<p class=\"p1\"><span class=\"s1\" style=\"color: #000000;\">When we\u00a0place\u00a0our launcher icons in\u00a0the mipmap-[density] folders, \u00a0we change the launcher icon references in the AndroidManifest.xml file\u00a0to reference the mipmap\/ location. Following code snippet shows\u00a0the manifest file referencing the ic_launcher icon to\u00a0the mipmap\/ folder.<\/span><\/p>\n<p class=\"p1\"><span style=\"color: #000000;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-31851\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/01\/Screen-Shot-2016-01-28-at-12.34.55-am.png\" alt=\"Screen Shot 2016-01-28 at 12.34.55 am\" width=\"663\" height=\"141\" \/><\/span><\/p>\n<h3><span style=\"color: #000000;\">Nexus 6 device example<\/span><\/h3>\n<p class=\"p1\"><span style=\"color: #000000;\"><span class=\"s1\"><span style=\"color: #000000;\">The Nexus 6 has\u00a0screen display at a resolution of 2560 x 1440. This translates to ~ 730 x 410 dp.<\/span>\u00a0<\/span>It has a quantized density of 560 dpi, which falls in between the xxhdpi and xxxhdpi. \u00a0For the<\/span> Nexus 6, the platform will scale down xxxhdpi assets, but if those aren\u2019t available, then it will scale up xxhdpi assets which might look\u00a0blurred due to scaling up.\u00a0Provide at least an xxxhdpi app icon so that\u00a0devices can display large app icons on the launcher by scaling it down without showing fuzziness.\u00a0An xxxhdpi app icon can be used on the launcher for an xxhdpi device.<\/p>\n<p class=\"p1\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-31852\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/01\/Screen-Shot-2016-01-28-at-12.56.06-am.png\" alt=\"Screen Shot 2016-01-28 at 12.56.06 am\" width=\"788\" height=\"279\" \/><\/p>\n<h3 class=\"p1\">Side effect<\/h3>\n<p class=\"p1\"><span class=\"s1\"><span style=\"color: #000000;\">Adding xxxhdpi versions will provide a sharper visual experience on the Nexus 6, but it will also increase your apk size.<\/span>\u00a0<\/span><\/p>\n<p class=\"p1\">Thanks for reading!<\/p>\n<p class=\"p1\">Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Android introduced mipmap drawables for providing more flexibility to design the launcher icons. mipmap first introduced in Android Jelly Beans 4.3. \u00a0If you are building different versions of your app for different densities, you should know about the mipmap resource directory.\u00a0 This is exactly like normal drawable folder resources, except it does not participate in [&hellip;]<\/p>\n","protected":false},"author":150,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":70},"categories":[518,1772,1],"tags":[3066,3065],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/31846"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/150"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=31846"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/31846\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=31846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=31846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=31846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}