[Disclaimer: First of all I know there are many posts about the drawable and the mipmap folder, I read a descent bunch of them]
From the book Android Programming - The Big Nerd Ranch Guide there is an example in which I have to insert an icon next to some text on a Button
. For higher resolution screens it would make sense to include multiple sizes of the icon. In their solution they have all their images in many different Drawable folders with different resolution sizes of the image.
I got it working by just putting the icons in the drawable folder after a lot of trial and error to get it working in the mipmap folder:
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/next_button"
android:text="@string/next_button"
android:drawableRight="@drawable/arrow_right/"/>
However, I got some confusion about how it works:
From here I got some of my confusion:
The mipmap folders are for placing your app icons in only.
What does that mean? From google translate I get:
icon: a symbol or graphic representation on a screen of a program, option, or window, especially one of several for selection.
I finally understood the difference uses between mipmap and the drawable folder by looking at the official google documentations of the resource folder (res/).
They say when to use mipmap:
Drawable files for different launcher icon densities. For more information on managing launcher icons with mipmap/ folders, see Managing Projects Overview.
And when to put something in your drawable folder:
Bitmap files (.png, .9.png, .jpg, .gif) or XML files that are compiled into the following drawable resource subtypes:
Bitmap files
- List item
- Nine-Patches (re-sizable bitmaps)
- State lists Shapes Animation
- drawables
- Other drawables
- See Drawable Resources
Also noticeable is there is for the launcher icon by default multiple folders with different resolutions but for the drawable folder there is not. Android OS looks for these folder with special names, called qualifiers. For instance for the drawable folders there are these qualifiers and more:
These qualifiers are appended to these resource folder names like drawable-ldpi, drawable-hdpi and drawable-xdpi so the android operating system will look into these folders to find the best resolution of the files in the folders.
Hope this helps anyone. I found this hard to find.