我替换了所有地方的所有图像(我的意思是在 drawable 文件夹和所有 Windows Assets 文件夹和 iOS Resources 文件夹中),但它仍然向我显示应用程序的默认 Xamarin 图标.我也试过这段代码,但它似乎也不起作用.有人能告诉我解决办法吗?
[程序集:应用程序(Icon = "@drawable/icon")] 解决方案更新图标和名称 (Android)
如果您更改了图标名称,请确保更新 MainActivity.cs
上的参考[Activity(Label = "MyName", Icon = "@mipmap/myicon", Theme = "@style/MainTheme"]公共类 MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity{}您可能还需要更新对 icon.xml 中的 launcher_foreground 和 mipmap-anydpi 中的 icon_round.xml 的引用 文件夹.
总结(Android)图标未更新时的问题 (Android)
Xamarin Forms/Android 在每个 mipmap 文件夹(mipmap-mdpi、mipmap-hdpi、mipmap-xhdpi 等)中放置 2 个图标 - icon.png 和 launcher-foreground.png.
替换每个 mipmap 文件夹中的这两个图像.我保留了相同的名称,但应该可以使用不同的名称.
如果应用程序在清理/重新构建解决方案后仍然使用默认图标进行部署,则原始/默认图标可能仍然存在于 Android 项目 obj 文件夹中.解决方法是从Android项目目录中删除obj文件夹.
iOS对于 iOS,请参阅 使用资产目录管理图标.下面提供了从链接页面中提取的摘要:
对于图标,可以将特殊的 AppIcon 图像集添加到应用项目的 Assets.xcassets 文件中.
要使用资产目录,请执行以下操作:
MacOs
MacOs 的指南是 Xamarin 的应用程序图标.Mac 应用.您需要考虑以下步骤:
在上面链接的文档中有详细说明.
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")]解决方案
Updating Icon and Name (Android)
If you changed the icon name(s) please ensure you update the reference on MainActivity.cs
[Activity(Label = "MyName", Icon = "@mipmap/myicon", Theme = "@style/MainTheme"] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity { }You may also need to update the reference to launcher_foreground in icon.xml and icon_round.xml in the mipmap-anydpi folder.
Summary (for Android)Issues if Icon Not Updated (Android)
Xamarin 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 the app still deploys with the default icons even after cleaning/re-built the solution 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.
iOSFor 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 the Assets.xcassets file in the app's project.
To use an Asset Catalog, do the following:
MacOs
The guide for MacOs is Application icon for Xamarin.Mac apps. You need to consider the following steps:
detailed in the linked docs above.
更多推荐
如何更改 Xamarin.Forms 中的应用程序图标?
发布评论