如何为我的Android应用程序设置图标?
当前回答
为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
其他回答
添加一个自动调整大小的应用程序启动器图标。
(Android工作室)
进入菜单文件*→新建→图像资产→选择启动器图标→选择图像文件。
它会自动调整大小。
完成了!
把你的图像放在drawables文件夹下的三个和设置它像这样。
Code
<application android:icon="@drawable/your_icon" >
....
</application>
你可以简单地安装一个安卓工作室武侠图标插件,它的名字是,请检查插件URL材质设计图标生成器,并检查这个动图的更多细节:
这主要是为了创建所需大小的图标,它将直接位于其文件夹中。
右键单击你的项目,去新建>其他> Android > Android图标集
然后按照向导上的说明进行操作
转到文件>新>图像资产。
从他们,你可以为你的图标创建图像资产。
之后,我们将得到图标图像在mipmap不同的格式像 hdpi、mdpi xhdpi、xxhdpi xxxhdpi。
现在去安德罗舱单xml
<application android:icon="@mipmap/your_Icon"> ....</application>
推荐文章
- PreferenceManager getDefaultSharedPreferences在Android Q中已弃用
- 在Android Studio中创建aar文件
- 修改抽射超时时间
- 如何通过数据从第二个活动到第一个活动时按回?——安卓
- 如何在android中获得当前前景活动上下文?
- 如何在Android中获取当前日期?
- 获取Android设备名称
- 在WebView中上传文件
- 加载HTML文件到WebView
- Android:为什么视图没有maxHeight ?
- 如何获得具有已知资源名称的资源id ?
- 在Android上将字符串转换为整数
- 为什么“System.out。”println“工作在Android?
- WebView显示err_cleartext_not_allowed尽管站点是HTTPS
- Android M权限:对shouldShowRequestPermissionRationale()函数的使用感到困惑