Flutter应用程序可以使用Android 8.0自适应图标吗? [英] Can I use Android 8.0 Adaptive Icons for a Flutter app?

查看:101
本文介绍了Flutter应用程序可以使用Android 8.0自适应图标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Android 8.0及更高版本的Flutter应用程序中使用自适应图标?即使

How can I use an Adaptive Icon for my Flutter app on Android 8.0 and up? The Create Image Asset dialog in Android Studio says "Project must be built with SDK 26 or later to use adaptive icons", even though my android build.gradle has CompileSDKVersion set to 27. If I define the icon in XML, it doesn't work, it seems to just use the regular legacy app icon.

推荐答案

它们工作得很好.

要使用该对话框,您需要在Android Studio中打开 Android模块.
Flutter.dev文章

To work with the dialog, you will need to open your Android module in Android Studio.
Flutter.dev article

菜单栏中的导航如下:Tools〜> Flutter〜> Open Android module in Android Studio或在项目视图的android文件夹中的任意位置单击鼠标右键,然后选择Flutter〜> Open Android module in Android Studio

Navigation is the following in the menu bar: Tools ~> Flutter ~> Open Android module in Android Studio or right-click anywhere in your android folder in the project view and select Flutter ~> Open Android module in Android Studio.

现在,您将能够正常使用资产对话框.

Now you will be able to use the asset dialog normally.

如果在 Flutter项目中对话框不起作用,则可以在 Android项目中轻松创建自适应图标 ,然后复制必要的文件,

If your dialog does not work in your Flutter project, you can easily create an adaptive icon in an Android project and then copy the necessary file, which are:

  • ic_launcher_background.xml(可绘制),如果您选择颜色,我认为它位于

  • ic_launcher_background.xml (drawable), I think that this is located in values if you chose a color

ic_launcher_foreground.xml(drawable-v24)

ic_launcher_foreground.xml (drawable-v24)

ic_launcher.xml,如果已创建ic_launcher_round.xml(mipmap-anydpi-v26)

ic_launcher.xml and if you created it ic_launcher_round.xml (mipmap-anydpi-v26)

所有ic_launcher.pngic_launcher_round.png(将mipmap-hdpi转换为mipmap-xxxhdpi)以获得旧版支持.我想如果您的最低SDK要求高于 25

all ic_launcher.png and ic_launcher_round.png (mipmap-hdpi to mipmap-xxxhdpi) for legacy support. I suppose that these are not needed if your minimum SDK requirement is higher than 25

这将为我涵盖所有内容.现在,在AndroidManifest.xml中为您的应用程序指定android:icon="@mipmap/ic_launcher",即在<application>标记中,并在需要时指定android:roundIcon:"@mipmap/ic_launcher_round".

This would cover everything for me. Now, in your AndroidManifest.xml specify android:icon="@mipmap/ic_launcher" for your application, i.e. in your <application> tag, and if needed android:roundIcon:"@mipmap/ic_launcher_round".

这篇关于Flutter应用程序可以使用Android 8.0自适应图标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆