简体   繁体   English

如何在 Flutter 中设置 Android 图标

[英]How to set up Android Icons in Flutter

I am trying to set up icons for Android in Flutter.我正在尝试在 Flutter 中为 Android 设置图标。

I want an icon to show in the launch screen (when the app is starting) and a different icon to show on the home screen in Android.我希望在启动屏幕上显示一个图标(当应用程序启动时),并在 Android 的主屏幕上显示一个不同的图标。

First I have configured this using launch_screen.xml and drawable folders.首先,我使用launch_screen.xmldrawable文件夹进行了配置。 launch_screen.xml in res\layout folder I configured like so:我配置的res\layout文件夹中的launch_screen.xml如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/launch_screen" android:scaleType="centerCrop" />
</RelativeLayout>

I have then placed launch_screen.png icon in drawable folders.然后我将launch_screen.png图标放在可绘制文件夹中。

This worked perfectly until I changed the minimum supported version of Android from 28 to 29. I have not changed target version from 31. After this the behavior has changed and Android (or Flutter?) started using icons from mipmap folders which look really ugly in the launch screen.在我将支持的最低 Android 版本从 28 更改为 29 之前,这一直很有效。我没有从 31 更改目标版本。在此之后,行为发生了变化,Android(或 Flutter?)开始使用 mipmap 文件夹中的图标,这些图标看起来真的很难看启动屏幕。

I tried to modify ic_launcher.xml and ic_launcher_round.xml files in mipmap-anydpi-v26 folder, and that did something, but not quite what I wanted.我尝试修改mipmap-anydpi-v26文件夹中的ic_launcher.xmlic_launcher_round.xml文件,这做了一些事情,但不是我想要的。

This changed both the icon in the app folder in Android as well as the launch screen.这改变了 Android 应用文件夹中的图标以及启动屏幕。 What's worse when the phone is using round icons, the launch screen is also displaying a round icon (or rather it crops the square image to a round shape)!更糟糕的是,当手机使用圆形图标时,启动屏幕也会显示圆形图标(或者更确切地说,它会将方形图像裁剪为圆形)!

How can I specify the icon I want for the launch screen without affecting the home page icons?如何在不影响主页图标的情况下为启动屏幕指定我想要的图标?

I do not want to use the splash screen as it requires me to specify how long I want it to show which I obviously cannot know in advance for every phone in the world.我不想使用启动画面,因为它要求我指定我希望它显示多长时间,我显然无法提前知道世界上的每部手机。 I just want something to show up when the app is starting so that user on a slow phone knows that it is happening and his phone has not just crashed.我只想在应用程序启动时显示一些东西,以便使用慢速手机的用户知道它正在发生并且他的手机不仅仅是崩溃了。

seek an image on your computer name it ic_logo_scree then past it in the drawer folder with ctrl+v在您的计算机上查找图像,将其命名为 ic_logo_scree,然后使用 ctrl+v 将其粘贴到抽屉文件夹中

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/ic_logo_scree" android:scaleType="centerCrop" />
</RelativeLayout>

i thing it a name conflit我认为这是一个名字冲突

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM