Android应用程序中未显示应用程序图标

Android应用程序中未显示应用程序图标

本文介绍了Xamarin.Forms Android应用程序中未显示应用程序图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么我的Xamarin.Forms Android应用程序具有默认的机器人图标.

I cannot figure out why my Xamarin.Forms Android app has the default robot icon.

这是我现在拥有的结构:

Here is the structure I have now:

这是我在"MainActivity.cs"中拥有的内容:

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

这是"AndroidManifest.xml"中的内容:

And here is what I have in "AndroidManifest.xml":

<application android:label="My App Name" android:icon="@mipmap/icon"></application>

在"icon.xml"中:

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>

我在网上找到了一些解决方案,建议将图标移到"drawable"文件夹中,但是我不确定这些解决方案是否最新.我正在使用Visual Studio2019.请告知.

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.

推荐答案

mipmap-anydpi-v26 意味着对于SDK 26或更高版本,它使用XML文件文件夹中的文件来使用自适应图标.

mipmap-anydpi-v26 means for SDK 26 or greater, it uses the files in the folder of the XML file to use adaptive icons.

如果设备版本低于26,则可以检查icon.png是否正确存储在文件夹中.如果版本大于或等于26,则可以检查icon.xml.

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.

最简单的方法是将icon.png放入Resources/drawable文件夹中,然后使用:

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

这篇关于Xamarin.Forms Android应用程序中未显示应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:29