Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Oreo Adaptive Icons

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

like image 553
Mathias Kirkegaard Avatar asked Dec 18 '17 08:12

Mathias Kirkegaard


1 Answers

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
    {
like image 115
Marvin Dickhaus Avatar answered Oct 05 '22 06:10

Marvin Dickhaus