如何为我的Android应用程序设置图标?


当前回答

1 .在Photoshop或Coreldraw中创建图标,大小为256*256

注意,如果你想要一个透明的图标,请使用PNG文件格式

2 .在https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html上传你的图标

3 .在这个网站上进行设置

4 .点击下载按钮,下载网页自动生成的zip文件

5 .解压压缩文件并复制res文件夹到你的项目库

注意,res文件夹包含所有大小图标

6-最后你需要设置清单使用图标

<application android:icon="@drawable/your_icon" >
.... 
</application>

其他回答

你可以简单地安装一个安卓工作室武侠图标插件,它的名字是,请检查插件URL材质设计图标生成器,并检查这个动图的更多细节:

这主要是为了创建所需大小的图标,它将直接位于其文件夹中。

我发现这个工具最有用。

上传图片。 下载压缩包。 将其提取到您的项目中。 完成

https://romannurik.github.io/AndroidAssetStudio/

1 .在Photoshop或Coreldraw中创建图标,大小为256*256

注意,如果你想要一个透明的图标,请使用PNG文件格式

2 .在https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html上传你的图标

3 .在这个网站上进行设置

4 .点击下载按钮,下载网页自动生成的zip文件

5 .解压压缩文件并复制res文件夹到你的项目库

注意,res文件夹包含所有大小图标

6-最后你需要设置清单使用图标

<application android:icon="@drawable/your_icon" >
.... 
</application>

最好是通过Android Studio而不是文件浏览器来更新所有图标文件,每个图标文件的分辨率都是正确的。

要这样做,请到菜单文件→新建→图像资产。这将打开一个新的对话框,然后确保Launcher Icons被选中(这是默认的),然后浏览到图标的目录(它不必在项目资源中),然后一旦选中,确保其他设置是你喜欢的,然后点击完成。

现在所有的分辨率都保存在各自的文件夹中,你不必担心自己复制或使用工具等。

不要忘记透明背景的“Shape - none”。

请不要擅自修改我的答案。

为android应用程序定义图标

<application android:icon="drawable resource">
.... 
</application> 

https://developer.android.com/guide/topics/manifest/application-element.html


如果你的应用适用于多种设备

你应该为所有广义屏幕密度创建单独的图标, 包括低、中、高、超高密度屏幕。这 确保图标在的范围内正确显示 可以安装应用程序的设备…


尺寸及格式

启动器图标应该是带有alpha通道的32位png 透明度。完成的启动器图标尺寸对应于 给定广义屏幕密度如下表所示。


将图标放置在mipmap或可绘制文件夹中

android:icon="@drawable/icon_name"或android:icon="@mipmap/icon_name"

developer.android.com/guide说,

此属性必须设置为对可绘制资源的引用 包含图像(例如“@drawable/icon”)。

关于启动器图标android-developers.googleblog。com说,

最好的做法是把你的应用程序图标放在mipmap-文件夹(而不是 可绘制-文件夹),因为它们用于不同的分辨率 器件的电流密度。例如,xxxhdpi应用程序图标可以是 用于xxhdpi设备的启动器上。

来自谷歌(Android Framework)的Dianne Hackborn说,

如果你为不同的应用程序构建不同的版本 密度,您应该了解“mipmap”资源目录。 这与“可绘制的”资源非常相似,只是它不是 在创建不同apk时参与密度剥离 目标。

对于启动器图标,AndroidManifest.xml文件必须引用mipmap/ location

<application android:name="ApplicationTitle"
         android:label="@string/app_label"
         android:icon="@mipmap/ic_launcher" >

再引用一下这个

You want to load an image for your device density and you are going to use it "as is", without changing its actual size. In this case you should work with drawables and Android will give you the best fitting image. You want to load an image for your device density, but this image is going to be scaled up or down. For instance this is needed when you want to show a bigger launcher icon, or you have an animation, which increases image's size. In such cases, to ensure best image quality, you should put your image into mipmap folder. What Android will do is, it will try to pick up the image from a higher density bucket instead of scaling it up. This will increase sharpness (quality) of the image.

此外,您可以读取mipmap和可绘制的文件夹


易于生成资产的工具

Android Asset Studio by romannurik.github Android Asset Studio by jgilfelt.github Image Asset Studio(from Android Studio) 材质图标生成器 Android材质设计图标生成器插件github.com/konifar 从SVG文件生成android资产的脚本

阅读更多信息:https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html