如何为我的Android应用程序设置图标?
当前回答
转到文件>新>图像资产。
从他们,你可以为你的图标创建图像资产。
之后,我们将得到图标图像在mipmap不同的格式像 hdpi、mdpi xhdpi、xxhdpi xxxhdpi。
现在去安德罗舱单xml
<application android:icon="@mipmap/your_Icon"> ....</application>
其他回答
右键单击你的项目,去新建>其他> Android > Android图标集
然后按照向导上的说明进行操作
转到文件>新>图像资产。
从他们,你可以为你的图标创建图像资产。
之后,我们将得到图标图像在mipmap不同的格式像 hdpi、mdpi xhdpi、xxhdpi xxxhdpi。
现在去安德罗舱单xml
<application android:icon="@mipmap/your_Icon"> ....</application>
为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
把你的图像放在drawables文件夹下的三个和设置它像这样。
Code
<application android:icon="@drawable/your_icon" >
....
</application>
把你的图像在mipmap文件夹和设置在清单文件… 像
<application android:icon="@mipmap/icon" android:label="@string/app_name" >
....
</application>
App文件夹目录:
图标大小和格式:
推荐文章
- 如何更改Android版本和代码版本号?
- Android Studio突然无法解析符号
- 应用程序重新启动而不是恢复
- 如何设置整个应用程序在纵向模式?
- Android中文本的阴影效果?
- 以编程方式设置TextView的布局权重
- Android -如何覆盖“后退”按钮,所以它不完成()我的活动?
- 如何从通知点击发送参数到一个活动?
- 导航目标xxx对于这个NavController是未知的
- 使用ConstraintLayout均匀间距的视图
- 文件google-services错误。模块根文件夹中缺少Json。谷歌服务插件没有它就不能正常工作。
- 如何以编程方式创建ColorStateList ?
- forceLayout(), requestLayout()和invalidate()的用法
- 如何增加Android模拟器的存储?(INSTALL_FAILED_INSUFFICIENT_STORAGE)
- 你怎么知道布局已经画好了?