问题
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
- 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>
- In the MainActivity also update the
Icon
andRoundIcon
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