问题描述
你们中的任何人都成功利用了Oreo中引入的适用于xamarin android的自适应图标"吗?
Did any of you successfully make use of the "Adaptive Icons" for xamarin android, introduced in Oreo?
如果.png图像放置在Drawable文件夹中,但如果将它们放置在MipMap文件夹中,则我设法使它工作.
I managed to make it work, if the .png images are placed in the Drawable-folders, but not if they are placed in the MipMap-folders.
我已遵循此链接中的准则,并且在使用Android Studio时可以使用...我认为很奇怪吗?
I have followed the guidelines in this link, and it works when using Android Studio... weird I think?
https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive.html
推荐答案
感谢此博客文章我能够在Xamarin.Forms Android应用中使用自适应图标.
Thanks to this blog post I was able to use adaptive Icons in my Xamarin.Forms Android app.
涉及的步骤
- 使用Android Studios创建自适应图标 Image Asset Studio (请注意,在编辑器首次初始化之前,您可能需要一段时间才能在Android Studio中实际添加新的
Image Asset
.) - 创建启动器项目后,您可以在文件资源管理器中打开res目录.
- 将所有
mipmap-*
文件夹复制到Xamarin.Forms Android项目Resources
目录中. - 更新
AndroidManifest.xml
以包含新的icon
和roundIcon
资产
- Create an adaptive Icon using Android Studios Image Asset Studio (note that it takes a while before you can actually add a new
Image Asset
in Android Studio as the editor is first initializing.) - Once the Launcher Item is created you can open the res directory in file explorer.
- Copy all
mipmap-*
-folder into the Xamarin.Forms Android ProjectResources
directory. - Update the
AndroidManifest.xml
to contain the newicon
androundIcon
asset
<application android:label="MyApp"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:appCategory="productivity"></application>
- 在MainActivity中还更新
Icon
和RoundIcon
值
namespace MyApp.Droid
{
[Activity(Label = "MyApp", Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
这篇关于Xamarin Oreo自适应图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!