I recently installed one more Android SDK to Android Studio, the SDK version 4.4 (API level 19), and after using it with my project, it added a set of mipmap folders in the project's res folder (res/mipmap).
I neither understand why, or how to use them.
I read another question about it here on SO.
The answer to it said that:
The mipmap folders are for placing your app icons 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.
I still don't get the reason to this.
Why cant we just place the app icons in the res/drawable folders too?
Also, if only the app icon should be placed in the mipmap folders, how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)
Why cant we just place the app icons in the res/drawable folders too?
Oh, you can. Google doesn't recommend it, that's all.
Quoting myself from Version 6.5 of my book:
While
drawable resources might be removed when packaging an APK, such as for the
Gradle for Android split system for making density-specific editions of an app,
mipmap resources are left alone, apparently
This is because launcher icons may be pulled from a higher-density bucket than the regular device density that is used for all other drawables. Putting them in res/mipmap-*/ directories means that we won't inadvertently get rid of them as part of optimizing APK size.
(why they didn't handle this in a better way, I have no idea)
how do I create other drawable assets and place them in the drawable folders with the Android Studio Image Asset wizard? (Accessed by right clicking in the project, selecting New > Image Asset)
The Image Asset wizard only puts launcher icons in res/mipmap-*/ directories. If you choose the other icon types, they will go in res/drawable-*/. And, of course, the Image Asset wizard itself is optional.
Related
I feel irritating to develop the xamarin now since it is so not stable... i am intend to create splash screen for the android, however from what i seen from the xamarin documentation,however before i am able to achieve it, i need to add the resources to my project. Please see the following documentation
https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_1_-_android_resource_basics/
from the beginning the resource folder has been done to create all the mdpi , ldpi those folder... they skipped to teach us how to create those resource folder, so in the end, i tried to create a new folder which is named as drawable-mdpi and put some icon into it. In the end the files and folder name does not exist in the Resource.Designer.cs.
In the end my resources is unuseable... Google no solution
Earlier Xamarin project template used to have all Drawable folders by default. Now the template just has the mipmap folders. You need to create all the drawable folders manually by Right Clicking Resources Folder > Add > New Folder. Give names as "drawable-mdpi" "drawable-hdpi" and so on. You can then add images to them by Right Clicking respective folders > Add > Add Files. If the Image's Id doesn't appear in Resource.Designer.cs file, it might be due to some build error already existing. Try cleaning and re-building. Either Resource Id will appear in Resource.Designer.cs or the already existing error will pop-up fixing which your issue will be resolved.
I realized those documentation is the xamarin old documentation, by the default the xamarin created those folder already, however i dont know why the xamarin don't show when we create the new project and i still dont understand why only create 3 density which is hdpi, xhdpi and the xxdpi, is it the mdpi not longer use? I have no idea. However i will need to add those folder again in the project so i am able to see it.
There are many posts which suggest that you should use the mipmap folders for your app icons. This seems to have come in android 4.3
I intend to support older android devices (Android 2.3.3 and above).
I have:
minSDK: android-10
targetSDK: android-10
Does this mean I have to create drawable folders too ? What will happen if I put my app icons only in the mipmap folders and do not create drawable folders ? I only have a device with android 4.4.4 so I cannot test with earlier devices. What should I do ?
According to this post the mipmap folder are only to keep the app icons. The other images and icons used in application should be kept in associated drawable folders!
App icon(logo) should only be in mipmap folder. Placing the different size if images in the mipmap folder will show icons in every android phone. Drawble folder contain images which is used inside the app.
Short
You don't need to put app icon in drawable if you already have it in mipmap folder.
I am following the tutorials in the Big Nerd Ranch book for android but that book is structured for Eclipse + ADT.
I am trying to add an arrow icon to a button and I have folders (drawable-hdpi, drawable-mdpi, drawable-xhdpi) that contain sets of identical images. Ideally I would like these folders to appear in the drawable folder but whether I copy and paste or drag these folders it doesn't seem to work. They appear in the packages section instead, but when this happens I can't seem to reference them from xml files in the layout folder.
The best I can do is drag/copy the files (not the folder)into the drawable folder, in which case they stay there and I am able to use them. The problem with this is I can have, at most, one pixel density for the set of images that is in there. The only way I can think of is if I change the names of all of them so that the problem of overwriting is gone.
However in the mipmap folder in the ic_laucher.png folder there are four files of the same name, except there are greyed out density descriptions beside them. How is this done?
What should I do?
As you can see I have now added the images using the file system. I am still unable to reference these using the resource name however. I am still not sure why.
What you are seeing in the mipmap "folder" is just some UI magic. The Android project view in Android studio will combine all resources with the same name into a single entry like you are seeing for ic_launcher.png to make it easier to view your resources.
Behind the scenes, this still uses different folders on disk. If you open up your project in Windows Explorer, you will see separate folders for mipmap-xhdpi, mipmap-mdpi, etc.
The same is true for your drawable folders. You still want to keep your images in separate density-specific folders on disk. Android Studio will then display them to you as if they were all in the same drawable folder in the Android project view. You cannot physically move your density specific folders beneath the drawable folder.
How do the drawable folders work nowadays?
I used to be able to just add folders named drawable-mdpi and such to get image resources, but this feature has seemingly disappeared. Image assets doesn't allow me to add image assets that aren't icons without messing them up and manually adding the drawable folders I need doesn't work any more as android can no longer find the resources.
How does android look for drawables now and how can I add prescaled images to my projects manually?
When I overwrite an image asset in Android Studio, for example the default ic_launcher, the IDE keeps showing the old image - no matter what I do, the image is never refreshed in the IDE (the deployed app uses the correct one). After a while you are not sure which files you have already changed and which are to be changed. You can prepare a list and check the items, but it would be nice to see the actual files in the IDE.
Is there any way to force this incredibly buggy IDE to 'sync' the cached image resources with those actually chosen by the developer?
I am using Android Studio 1.1.
Cheers
Open your src/drawable folder and make sure that this ic_launcher is not in any folder of your drawable, it means that in your mdpi, hdpi, etc... folder is this icon, then you can delete it in each folder on your drawable or you can replace it with yours (with the same name, if you don't want to replace the ic_launcher on the whole code), and Clean / rebuild the project.