Xamarin Oreo Adaptive Icons

冷暖自知 提交于 2020-07-18 04:22:09

问题


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


回答1:


Thanks to this blog post I was able to use adaptive Icons in my Xamarin.Forms Android app.

Steps involved

  1. 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.)
  2. Once the Launcher Item is created you can open the res directory in file explorer.
  3. Copy all mipmap-*-folder into the Xamarin.Forms Android Project Resources directory.
  4. Update the AndroidManifest.xml to contain the new icon and roundIcon asset
<application android:label="MyApp"
               android:icon="@mipmap/ic_launcher"
               android:roundIcon="@mipmap/ic_launcher_round"
               android:appCategory="productivity"></application>
  1. In the MainActivity also update the Icon and RoundIcon values
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
    {



回答2:


Supposedly there is a bug in xamarin android mipmap folder that is well explained here as well as in the Release Notes

There are also some bugzilla reports :

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

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

Hope it helps!



来源:https://stackoverflow.com/questions/47864285/xamarin-oreo-adaptive-icons

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!