【发布时间】:2020-04-26 14:41:05
【问题描述】:
运行 Flutter 应用后,它会正确部署到 Android 虚拟设备。
在虚拟设备中,我可以注意到为应用选择的图标在其他现有应用中正确显示。
但是,当我点击查看正在运行的进程时,Flutter 应用程序窗口的顶部会出现一个 Android 图标。
图标是手动添加的,如here 所述。
如何更改此默认图标以使用我的?
【问题讨论】:
标签: android flutter mobile-application
运行 Flutter 应用后,它会正确部署到 Android 虚拟设备。
在虚拟设备中,我可以注意到为应用选择的图标在其他现有应用中正确显示。
但是,当我点击查看正在运行的进程时,Flutter 应用程序窗口的顶部会出现一个 Android 图标。
图标是手动添加的,如here 所述。
如何更改此默认图标以使用我的?
【问题讨论】:
标签: android flutter mobile-application
您可以使用的我最喜欢的库之一 它将为您生成 iOS 和 android 图标 https://pub.dev/packages/flutter_launcher_icons
【讨论】:
再次检查您的 AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.snapio">
<application
android:name="io.flutter.app.FlutterApplication"
android:label="flutter"
android:icon="@mipmap/ic_launcher">
您必须在此文件中更改您的图标名称。
【讨论】:
<application ... android:icon="@mipmap/ic_launcher">,并且mimap文件夹有新图标,所以不知道为什么模拟器显示默认的android图标。你认为这可能是什么原因?它是否缺少特定的解决方案?我目前的分辨率是 hdpi、mdpi、xhdpi、xxhdpi 和 xxxhdpi。
对于 Android 10,您必须为其提供自适应图标才能显示在任务切换器中。更多信息在这里:https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive
【讨论】:
通过像这样设置 flutter_icons 标签,从 pubspec.yaml 更改 Flutter 中的应用程序图标:
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "images/icon/icon.png" # your full path in assets directory
在pubspec.yaml
中添加flutter_launcher_icons作为开发依赖dev_dependencies:
flutter_launcher_icons: "^0.9.2"
最后更新依赖并生成图标
flutter pub get
flutter pub run flutter_launcher_icons:main
【讨论】: