Xamarin Oreo Adaptive Icons

时间:2017-12-18 08:06:13

标签: xamarin.android android-8.0-oreo

Did any of you successfully make use of the "Adaptive Icons" for xamarin android, introduced in Oreo?

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.

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

2 个答案:

答案 0 :(得分:4)

感谢this blog post,我能够在Xamarin.Forms Android应用中使用自适应图标。

涉及的步骤

  1. 使用Android Studios Image Asset Studio创建自适应图标(请注意,在编辑器首次初始化之前,您可能需要一段时间才能在Android Studio中实际添加新的Image Asset。)
  2. 创建启动器项目后,您可以在文件资源管理器中打开res目录。
  3. 将所有mipmap-*文件夹复制到Xamarin.Forms Android项目Resources目录中。
  4. 更新AndroidManifest.xml以包含新的iconroundIcon资产
<application android:label="MyApp"
               android:icon="@mipmap/ic_launcher"
               android:roundIcon="@mipmap/ic_launcher_round"
               android:appCategory="productivity"></application>
  1. 在MainActivity中,还更新IconRoundIcon的值
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
    {

答案 1 :(得分:2)

据说xamarin android mipmap文件夹中有一个错误,可以很好地解释here以及Release Notes

还有一些bugzilla报告:

https://bugzilla.xamarin.com/show_bug.cgi?id=56146

https://bugzilla.xamarin.com/show_bug.cgi?id=59904

希望它有所帮助!