我正在做一个React Native应用程序。我想自定义应用程序图标(意味着你点击启动应用程序的图标)。我在谷歌上搜索过,但我一直在寻找不同类型的图标,它们指的是不同的东西。如何将这些类型的图标添加到应用程序中?


当前回答

iOS图标

在Images.xcassets中设置AppIcon。 添加9个不同大小的图标: 29 pt 29 pt * 2 29 pt * 3 40 pt * 2 40 pt * 3 57分 57 pt * 2 60 pt * 2 60 pt * 3。

图像。Xcassets看起来是这样的:

Android图标

将ic_launcher.png放入[ProjectDirectory]/android/app/src/main/res/mipmap-*/文件夹中。 mimmap -hdpi中的72*72 ic_launcher.png。 mimmap -mdpi中的48*48 ic_launcher.png。 mimmap -xhdpi中的96*96 ic_launcher.png。 144*144 ic_launcher.png mimmap -xxhdpi。 mimmap -xxxhdpi中的192*192 ic_launcher.png。

2019年更新

react native的最新版本也支持圆形图标。对于这种特殊情况,您有两个选择:

A.添加圆形图标: 在每个mipmap文件夹中,在ic_launcher.png文件中添加一个同样大小的圆形版本,称为ic_launcher_round.png。

B.移除圆形图标: 在你的projectfolder /android/app/src/main/AndroidManifest.xml中删除一行android:roundIcon="@mipmap/ic_launcher_round"并保存它。

否则构建将抛出错误。

其他回答

这有助于人们努力寻找更好的网站来生成图标和飞溅屏幕

制作应用图标(android和ios都有用) APE工具(android和ios都有用) 图标集创建器(仅适用于ios) android Asset Studio(仅适用于android +推荐*)

如果你想在React Native上导入图标而不需要图片,那么React - Native -vector-icons将是最好的选择。如果您不想下载图标并在项目中使用它,您可以使用它。

在React-Native项目中为Android设备设置应用程序启动图标:

Take a high resolution image of your logo and place it inside your project directory. Preferably in [Project-DIR]/android/app/src/main/res/ Open Android Studio and run your React-native project. In Android Studio's Project window, select the Android view Right-click the res folder and select New > Image Asset A "Configure Image Asset" window will open; Locate your high resolution image and place set it as your "Foreground layer". Set your "Background Layer" if applicable Click "Next" and continue to finish. Run your application again to see the new app launch icon.

官方文档可以在这里找到:https://developer.android.com/studio/write/image-asset-studio

更新2022

因为阿尔莫罗的答案已经不复存在了

Android和iOS图标

你现在可以在iOS和Android上用一个命令生成圆形图标:

npx icon-set-creator create ./path/to/icon.png

我强烈建议使用至少1024x1024像素的图标

自适应Android图标

npx icon-set-creator create -b <background> -f <foreground> -A

background—颜色(例如:“#ffffff”)或图像资产(例如:“资产/图片/ christmas-background.png”)

前景-图像资产(例如:“资产/图片/ christmas-foreground.png”)

使用这个库可以使您的工作更容易。 它将自动化您的图标生成过程

https://www.npmjs.com/package/@bam.tech/react-native-make