Issue
[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:
- People often say that only the app icon should be placed in the mipmap folders, is that true? What is the app icon? Others say that only the launcher icons should be placed there while still others say that only icons should be placed there. Which one is it, they are mutually exclusive options!
- I can't auto-complete into the mipmap folder within Android Studio which makes me think that I have to put everything into my drawable folder since there Android Studio does auto-completion for me. But, by default the drawable folder has no sub-folders. This leaves me to believe that the drawable folder should no longer be used for images of different resolutions, since why else would the default be no folders, so everyone can make spelling mistakes..
- When would it not make sense to have icons available in different resolutions? I can't imagine someone not wanting the highest possible resolution..
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.
Solution
Different uses of mipmap and drawable folder
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
Qualifiers appended to folder-names have special meaning in android
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:
- ldpi
- hdpi
- xdpi
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.
To answer the questions from above:
- People make the mistake of using the term icon when they actually mean launcher icon. The launcher icon should be placed in the mipmap and is there by default.
- Nothing besides the launcher icon should be placed in the mipmap
- Android provides configuration qualifiers to make it easier to change the app based on specific device settings like screen resolution and screen orientation. It makes a lot of sense to include different size versions since downscaling and upscaling can then be done much more accurate to fit all kind of screen sizes.
Hope this helps anyone. I found this hard to find.
Answered By - Joop
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.