问题
I cannot figure out why my Xamarin.Forms Android app has the default robot icon.
Here is the structure I have now:
And here is what I have in "MainActivity.cs":
[Activity(Label = "My App Name", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
And here is what I have in "AndroidManifest.xml":
<application android:label="My App Name" android:icon="@mipmap/icon"></application>
And in "icon.xml":
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/launcher_background" />
<foreground android:drawable="@mipmap/icon" />
</adaptive-icon>
Some solutions that I found online suggest moving the icons to the "drawable" folder, but I am not sure those solutions are up to date. I am using Visual Studio 2019. Please advise.
回答1:
mipmap-anydpi-v26 means for SDK 26 or greater, it uses the files in the folder of the XML file to use adaptive icons.
If your device version is lower than 26, you could check if the icon.png
is stored in the folders correctly. If the version greater than or equal to 26, you could check the icon.xml
.
By the way, the easiest way is put your icon.png into Resources/drawable
folder, then use like:
[Activity(Label = "My App Name", Icon = "@drawable/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
来源:https://stackoverflow.com/questions/58613457/application-icon-is-not-displayed-in-xamarin-forms-android-app