Mipmaps vs. drawable folders [duplicate]
Asked Answered
N

1

671

I'm working with Android Studio 1.1 Preview 1. I noticed that when I create a new project I'm getting the following hierarchy:

Enter image description here

Mipmap folders for different DPIs, no more different DPIs drawable folders.

Should I put all my resources in the mipmap folders, or just the app icon?

Nollie answered 21/1, 2015 at 10:48 Comment(4)
Check out this statement from the google blog spot link below :- "... because they are used at resolutions different from the device’s current density. For example, an xxxhdpi app icon can be used on the launcher for an xxhdpi device." This tells that some devices explicitly tries to use icons of different density rather than what current device density specifies. eg. some manufacturer might like to use bigger icons in the home screen than launcher screen, or smaller icons for notifications than than usual specification. We must thus identify such resources and place them in mipmap folders.Chang
The above comment is just an assumption on what I understand and might be wrong.Chang
There is quite a lot more info over here --> mipmap drawables for iconsIngamar
Google should add a Lint quick-fix for putting app-icons there. I've made a post about it here: code.google.com/p/android/issues/detail?id=219500Joo
E
953

The mipmap folders are for placing your app/launcher icons (which are shown on the homescreen) in only. Any other drawable assets you use should be placed in the relevant drawable folders as before.

According to this Google blogpost:

It’s best practice to place your app icons in mipmap- folders (not the drawable- folders) because they are used at resolutions different from the device’s current density.

When referencing the mipmap- folders ensure you are using the following reference:

android:icon="@mipmap/ic_launcher"

The reason they use a different density is that some launchers actually display the icons larger than they were intended. Because of this, they use the next size up.

Ebby answered 21/1, 2015 at 11:6 Comment(14)
To clarify, the "app icons" in the quoted section are referring to launcher icons, not necessarily other icons.Hogle
"because they are used at resolutions different from the device’s current density" what does this mean really? That's one of the most cryptic phrases in this release.Devilry
When you are using them in your code make sure you are using (R.mipmap.icon_name) not (R.drawable.icon_name).Esteban
@southerton When a resource from drawable is requested, a bitmap is chosen from the folder that matches the current density. For example, the Nexus 5 chooses drawables from XXHDPI. The launcher may choose an icon from a different folder. The Nexus 5 launcher uses icons from XXXHDPI. #25131577Siskin
@southerton The reason they use a different density is that some launchers actually display the icons larger than they were intended. Because of this, they use the next size up.Ingamar
What if I am using some images in my application which should change its size according to the pixel density of device? Should I place them in mipmaps or drawables? Please advice.Megaphone
I have a question. I have put all the appropriate images in all the appropriate folders, but when I try to make an ImageView with the `android:src = "@drawable/myimg"/>, I get cannot resolve. Do I need the image to also be in the drawable folder as well as the sub folders? I have been stuck on this for the last 4 and a half hours, thanks for your help!Anthocyanin
@NullPointer try @mipmap/myimg instead - as per comment #1 by Asthme.Ingamar
To be simple, Android system can take a bitmap in mipmap regardless of the screen resolution of the device where your app is installed. For example mipmap-xxxhdpi qualifier will provide launcher icon that can appear larger than usual on an xxhdpi device.Jari
can we choose different resolutions maually.. example xxxhdpiJeroldjeroma
any specific purpose to keep this new pattern where we already had /drawable-XXX/ to defined these?? Any one !!Injection
Where does it say that other images should be in drawable folder? What does the launchers do in order to get a different density of the icons? Isn't Mipmap a way to scale the images better, by combining them or something?Joo
@joel menu, tab, bottom and navigation drawer icons should go to mipmap or drawable?Corelli
what if i have scalable vector graphic? that can be resized to any resolution so there is no need for specifying resolutionVirtuosic

© 2022 - 2025 — McMap. All rights reserved.