【问题标题】:How to change android icon in flutter?如何在颤动中更改android图标?
【发布时间】:2020-04-26 14:41:05
【问题描述】:

运行 Flutter 应用后,它会正确部署到 Android 虚拟设备。

在虚拟设备中,我可以注意到为应用选择的图标在其他现有应用中正确显示。

但是,当我点击查看正在运行的进程时,Flutter 应用程序窗口的顶部会出现一个 Android 图标。

图标是手动添加的,如here 所述。

如何更改此默认图标以使用我的?

【问题讨论】:

    标签: android flutter mobile-application


    【解决方案1】:

    您可以使用的我最喜欢的库之一 它将为您生成 iOS 和 android 图标 https://pub.dev/packages/flutter_launcher_icons

    【讨论】:

      【解决方案2】:

      再次检查您的 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">
      

      您必须在此文件中更改您的图标名称。

      【讨论】:

      • 我已经设置了&lt;application ... android:icon="@mipmap/ic_launcher"&gt;,并且mimap文件夹有新图标,所以不知道为什么模拟器显示默认的android图标。你认为这可能是什么原因?它是否缺少特定的解决方案?我目前的分辨率是 hdpi、mdpi、xhdpi、xxhdpi 和 xxxhdpi。
      • 您可以尝试从您的手机中卸载该应用程序吗?然后再次运行。
      • 是的,卸载并再次安装,显示相同的android默认图标。此默认图标仅在具有 android 10.0 版本的模拟器中显示。在我使用 android 9.0 的物理设备中,新图标正确显示。由于在 9.0 中图标显示正确,所以可能是与 android 10.0 版本有关的问题。
      • 我有同样的问题,在应用程序抽屉中正确显示,但在切换应用程序时没有。卸载没有帮助。同样在 android 10
      【解决方案3】:

      对于 Android 10,您必须为其提供自适应图标才能显示在任务切换器中。更多信息在这里:https://developer.android.com/guide/practices/ui_guidelines/icon_design_adaptive

      【讨论】:

        【解决方案4】:

        通过像这样设置 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
        

        【讨论】:

          猜你喜欢
          • 2020-04-20
          • 2021-07-04
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-09-23
          • 1970-01-01
          • 2021-04-30
          • 2021-10-17
          相关资源
          最近更新 更多