I replaced all the images everywhere (by this I mean in drawable folders and all Windows Assets folders and iOS Resources folder), but it still shows me the default Xamarin icon for the app. I tried this code, too, but it doesn't seem to work either. Can someone tell me the solution?
[assembly: Application(Icon = "@drawable/icon")]
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).
If you changed the icon file name please ensure you update the Icon
reference in MainActivity.cs
:
[Activity(Label = "MyName", Icon = "@mipmap/myicon", Theme = "@style/MainTheme"] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity { }
You should also update the names of icon.xml
and icon_round.xml
in the mipmap-anydpi
folder to match to new icon name. If launcher-foreground.png
was renamed then update the value of <foreground...>
in corresponding icon.xml
.
png
's in mipmap folders with your new iconIcon
value in MainActivity.cs
icon.xml
and icon_round.xml
launcher-foreground.png
was changed then update value in icon.xml
. Eg: <adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android"> <background android:drawable="@color/my_launcher_background"/> <foreground android:drawable="@mipmap/my_launcher_foreground"/> </adaptive-icon>
obj
folder from Android project directoryXamarin Forms/Android puts 2 icons in each mipmap folder (mipmap-mdpi, mipmap-hdpi, mipmap-xhdpi, etc) - icon.png
and launcher-foreground.png
.
Replace both these images in each of the mipmap folders. I kept the same names but it should be possible to use a different name.
If you rename launcher-foreground.png
then you must update the values in icon.xml
and icon_round.xml
(or their equivalent new names). The value in the <foreground...>
tag references the icon/png. So, if launcher-foreground.png
was updated to my_launcher-foreground.png
this should be reflected in the icon.xml
(see step 4 in summary above).
If the icons still don't update even after cleaning/re-building it could be that the original/default icons still existed in the Android project obj
folder. The solution is to delete the obj
folder from the Android project directory.
For iOS, please see Managing Icons with Asset Catalogs. A summary taken from the linked page is provided below:
For icons, a special
AppIcon
image set can be added to theAssets.xcassets
file in the app's project.To use an Asset Catalog, do the following:
- Double-click the Info.plist file in the Solution Explorer.
- Click on the Visual Assets tab and click on the Use Asset Catalog button under App Icons.
- From the Solution Explorer, expand the Asset Catalog folder.
- Double-click the Media file to open it in the editor.
- Under the Properties Explorer the developer can select the different types and sizes of icons required.
- Click on given icon type and select an image file for the required type/size.
- Click the Open button to include the image in the project and set it in the xcasset.
The guide for MacOs is Application icon for Xamarin.Mac apps. You need to consider the following steps:
- Required image sizes and filenames
- Packaging the icon resources
- Using the icon
detailed in the linked docs above.
For Android try to set the icon app like this:
[Activity(Icon = "@drawable/icon")] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { ..... }
Make sure that you have changed all the icon images on all drawable folders ( drawable, drawable-hdpi, drawable-xhdpi and drawable-xxhdpi ).
For iOS I like set the app icons and splash screen with Asset Catalogs, here you can find a guide to how to use it:
https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/app-icons/
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