I'm new to Android development (using Mono for Android), I've read this, this this and a some other questions here on SO but I'm not sure on how to provide all necessary Icon files for my application.
drawable/
folder with an 48x48 px Icon.png file.drawable-hdpi/ic_launcher.png
(72x72 px)
drawable-mdpi/ic_launcher.png
(48x48 px)
drawable-xhdpi/ic_launcher.png
(96x96 px)
drawable-xxhdpi/ic_launcher.png
(144x144 px)
(I don't know why, but the Android Asset Studio did not generate the ldpi
version, so I resized myself a 36x36 icon.)
Now I'm lost
1. Should I maintain a 48x48 px copy in both drawable-mdpi/
and drawable/
?
If I keep the icon only in the drawable-mdpi/
, may the application crash on older devices / versions of the Android (because the default resource is missing)?
1. If I keep the icon only in the drawable/
(the fallback), what is the point in using drawable-mdpi/
at all?
Since I don't know exactly what to do, I'm left my project drawable folders as follows:
drawable/ic_launcher.png
(48x48 px)
drawable-hdpi/ic_launcher.png
(72x72 px)
drawable-ldpi/ic_launcher.png
(36x36 px)
drawable-mdpi/ic_launcher.png
(48x48 px)
drawable-xhdpi/ic_launcher.png
(96x96 px)
drawable-xxhdpi/ic_launcher.png
(144x144 px)
But it is still not clear for me.
EDIT:
If I provide all possible "alternative" resources, then the default (drawable/
) resource folder will become redundant, thus I could delete it. However I'm reluctant of not providing the default resources because it seems more reasonable to do the opposite: first provide the "default" resources and then provide "alternative" resources as needed.
A Launcher icon is a graphic that represents your application on the device's Home screen and in the Launcher window. The user opens the Launcher by touching the icon at the bottom of the Home screen. The Launcher opens and exposes the icons for all of the installed applications.
According to http://developer.android.com/design/style/iconography.html, the default launcher icon size should be 48 x 48 pixels.
On Android devices, launcher icons are generally 96×96, 72×72, 48×48, or 36×36 pixels (depending on the device), however Android recommends your starting artboard size should be 864×864 pixels to allow for easier tweaking.
This quote is a little long, but you should read though what the documentation has to say about this:
At runtime, the system ensures the best possible display on the current screen with the following procedure for any given resource: 1.The system uses the appropriate alternative resource Based on the size and density of the current screen, the system uses any size- and density-specific resource provided in your application. For example, if the device has a high-density screen and the application requests a drawable resource, the system looks for a drawable resource directory that best matches the device configuration. Depending on the other alternative resources available, a resource directory with the hdpi qualifier (such as drawable-hdpi/) might be the best match, so the system uses the drawable resource from this directory.
2.If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate.
However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.
So, the system will look for the best sized drawable for whatever device the application is running on. If the system is looking for a launcher icon of 48x48, it will look in drawable-mdpi/ first because the docs suggest you put a 48x48 icon in that folder. Since you've provided that already, there's no reason why the application would ever have to look in the drawable/ folder for a default image. Even if it did, it would not be beneficial since you've already provided an icon of the same size.
If you've provided even just one size of a particular drawable, your app shouldn't crash on any devices, even if the size you provided is very wrong. The image will just look bad in that case, because the system will load the single image you have provided. So, if you've got the image in the drawable-*dpi folders, you won't need a copy in drawable/.
TL;DR
No, you won't need to put a 48x48 copy of ic_launcher.png in the drawable folder if you've already got one in drawable-mdpi/, because the system will choose that one first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With