Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the mipmap folder in Xamarin.Android?

For app icons we should use the mipmap folder. Now I added the following folders to the Resources folder:

  • mipmap-hdpi
  • mipmap-ldpi
  • mipmap-mdpi
  • mipmap-xhdpi
  • mipmap-xxhdpi
  • mipmap-xxxhdpi

In each of these folders there is a ic_launcher.png for the app icon and the build action is AndroidResource.

Now I can't set the Application Icon in the Android Manifest. It doesn't appear there. What I'm missing?

I deleted the default icon in the drawable folder and removed the entry in Android Manifest. On build I got

No resource found that matches the given name (at 'icon' with value '@drawable/icon').
File: ...\SomeApp.Droid\obj\Debug\android\manifest\AndroidManifest.xml

There was an entry in MainActivity which was the old reference to Icon = @drawable/icon. Now I changed to Icon = @mipmap/ic_launcher and the error was gone.

like image 986
testing Avatar asked Aug 23 '16 15:08

testing


People also ask

What is mipmap folder?

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.

What is mipmap used for?

Android introduced mipmap drawables for providing more flexibility to design the launcher icons. mipmap first introduced in Android Jelly Beans 4.3. If you are building different versions of your app for different densities, you should know about the mipmap resource directory.

How do I change icons on xamarin app?

open these folders, copy the image to your Xamarin android folder like following screenshot(For example, I copy the image from mipmap-hdpi folder, then I put it in your mipmap-hdpi folder of xamarin. android project, mipmap-mdpi , mipmap-xhdpi , mipmap-xxhdpi , mipmap-xxxhdpi are executed same operation).


2 Answers

I manually edited the AndroidManifest.xml to use the mipmapfolder:

<application android:label="@string/app_name" android:icon="@mipmap/ic_launcher"></application>
like image 136
testing Avatar answered Sep 19 '22 15:09

testing


Tried these:

  1. I deleted all references to default icon.
  2. Deleted the icon in Drawable folder itself.
  3. Added the new reference to my mipmaps (in Resources) in Manifest. and still no resource match was found.

Additionally:

What I had to do was add the folders and icons in manually (i.e. right-click > add > new folder). I could not just drag and drop it in whereas doing so does not allow you to see the icon files inside folders either.

It seems the build action should automatically be set to newly added resources (ref). I'm not sure why a drag-and-drop to solution explorer would "hide" files in folders.

like image 38
Jnr Avatar answered Sep 21 '22 15:09

Jnr