android - 应用程序图标未显示在 Xamarin.Forms Android 应用程序中

标签 android xamarin.forms icons

我不明白为什么我的 Xamarin.Forms Android 应用有默认的机器人图标。

这是我现在的结构:

enter image description here

这是我在“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”中的内容:

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

在“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 Studio 2019。

最佳答案

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

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

顺便说一下,最简单的方法是将 icon.png 放入 Resources/drawable 文件夹中,然后像这样使用:

[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

关于android - 应用程序图标未显示在 Xamarin.Forms Android 应用程序中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58613457/

相关文章:

android - 防止第二个 ajax 调用等到第一个 ajax 调用完成

android - android studio 缺少返回语句

ios - 如何防止键盘覆盖我的 UI 而不是调整它的大小?

ios - Xamarin Forms - TapGestureRecognizer 不适用于 iOS

html - 在 Internet Explorer 中从图像中删除边框

安卓 "skimlinks-unlinked"

android - 如何创建带有交叉(x)按钮的EditText?

c# - Xamarin.Forms 不可点击的 ListView(移除选择涟漪效应)

html - 页脚中的居中和间距图标

angular - 如何应用主题或自定义星云图标?