如何为Android应用程序设置图标?
如果您有SVG图标,则可以使用此script生成您的Android图标集 .
右键单击您的项目,转到 New > Other > Android > Android Icon Set
然后按照向导上的说明进行操作
<application android:icon="drawable resource"> .... </application>
https://developer.android.com/guide/topics/manifest/application-element.html
您应该为所有通用屏幕密度创建单独的图标,包括低,中,高和超高密度屏幕 . 这可以确保您的图标可以在可以安装应用程序的设备范围内正确显示...
启动器图标应为32位PNG,带有透明的alpha通道 . 对应于给定的通用屏幕密度的完成的启动器图标尺寸显示在下表中 .
android:icon="@drawable/icon_name" 或 android:icon="@mipmap/icon_name"
android:icon="@drawable/icon_name"
android:icon="@mipmap/icon_name"
developer.android.com/guide says,
必须将此属性设置为对包含图像的可绘制资源的引用(例如“@ drawable / icon”) .
about launcher icons android-developers.googleblog.com says,
最佳做法是将应用程序图标放在mipmap文件夹(而不是可绘制文件夹)中,因为它们的分辨率与设备的当前密度不同 . 例如,可以在启动器上为xxhdpi设备使用xxxhdpi应用程序图标 .
Dianne Hackborn from Google (Android Framework) says ,
如果要为不同的密度构建不同版本的应用程序,则应该了解“mipmap”资源目录 . 这与“可绘制”资源完全相同,只是在创建不同的apk目标时不参与密度剥离 .
<application android:name="ApplicationTitle" android:label="@string/app_label" android:icon="@mipmap/ic_launcher" >
多一点引用this
您想为设备密度加载图像,并且您将使用它"as is",而不更改其实际大小 . 在这种情况下,您应该使用 drawables ,Android将为您提供最佳的图像 .
您想为设备密度加载图像,但此图像将按比例放大或缩小 . 例如,当您想要显示更大的启动器图标,或者您有动画时,需要这样做,这会增加图像的大小 . 在这种情况下,为了确保最佳图像质量,您应该将图像放入 mipmap 文件夹中 . Android会做的是,它会尝试从更高密度的存储桶中获取图像,而不是将其放大 . 这将增加图像的清晰度(质量) .
更多你可以阅读mipmap vs drawable folders
Android Asset Studio by romannurik.github
Android Asset Studio by jgilfelt.github
Image Asset Studio(from Android Studio)
Material Icon Generator.bitdroid.de
Android Material Design Icon Generator Plugin by github.com/konifar
A script to generate android assets from a SVG file
阅读更多:https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
你可以简单地安装Android工作室Martial图标插件,它的名字是请检查插件URL Material Design Icon Generator并查看此GIF以获取更多详细信息:
这主要用于创建具有所需大小的图标,并且它将直接位于其文件夹中 .
有点旧,但供将来使用:
Open Android Studio -> app/src/main/res -> Right Click -> Image Asset
选择图标图片复制此图片
将其粘贴到项目的 res/drawable 文件夹中
res/drawable
打开清单文件并设置
运行程序
如果您打算在多种设备上使用您的应用程序,则应将应用程序图标放入提供的不同 res/drawable... 文件夹中 . 在每个文件夹中,您应该包含一个48dp大小的图标:
res/drawable...
drawable-ldpi (120 dpi,低密度屏幕) - 36px x 36px
drawable-ldpi
drawable-mdpi (160 dpi,中密度屏幕) - 48px x 48px
drawable-mdpi
drawable-hdpi (240 dpi,高密度屏幕) - 72px x 72px
drawable-hdpi
drawable-xhdpi (320 dpi,超高密度屏幕) - 96px x 96px
drawable-xhdpi
drawable-xxhdpi (480 dpi,超高密度屏幕) - 144px x 144px
drawable-xxhdpi
drawable-xxxhdpi (640 dpi,额外超高密度屏幕) - 192px x 192px
drawable-xxxhdpi
然后,您可以在 AndroidManifest.xml 文件中定义图标:
AndroidManifest.xml
<application android:icon="@drawable/icon_name" android:label="@string/app_name" > .... </application>
我发现this tool最有用 .
上传图片 .
下载一个拉链 .
提取到您的项目中 .
Done
http://romannurik.github.io/AndroidAssetStudio/
这很简单 .
现在只需转到菜单文件→新建→图像资产 . 这将打开一个新的对话框,然后确保选中了启动器图标(默认情况下是这样),然后浏览到您的图标目录(它不必在项目资源中),然后一旦选中,请确保其他设置是你喜欢和完成的 .
现在所有分辨率都保存在各自的文件夹中,您不必担心自己复制或使用工具等 .
不要忘记透明背景的“形状 - 无” .
使用自动添加应用程序启动器图标浆纱 .
(Android studio)
转到菜单文件*→新建→图像资源→选择启动器图标→选择图像文件 .
它会自动重新调整大小 .
完成!
1-Create Your icon in Photoshop Or Coreldraw by size 256*256
请注意,如果您想拥有透明图标,请使用PNG文件格式
2-Upload Your icon in https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
3-Set your setting on this site
4-Download the zip file automatically created by the webpage by clicking on download button
5-Extract the zip file and copy res folder to you project library
请注意,res文件夹包含所有大小的图标
6-finally you need to set the manifest to use icon
<application android:icon="@drawable/your_icon" > .... </application>
将图像放在三个中的任何一个下的drawables文件夹中,并将其设置为这样 .
Code
您必须遵循以下步骤:
现在,您可以使用新图像运行并查看应用程序图标 .
快乐编码:) :)
转到文件 - > new-> ImageAsset .
从他们可以为您的图标创建图像资产 .
之后我们将获得mipmap中的图标图像,如hdpi,mdpi,xhdpi,xxhdpi,xxxhdpi .
现在转到AndroidManifest.xml
<application android:icon="@mipmap/your_Icon"> ....</application>
将您的图像放在 mipmap 文件夹中并在清单文件中设置...如同
mipmap
<application android:icon="@mipmap/icon" android:label="@string/app_name" > .... </application>
App Folder Directory :
Icon Size & Format :
您可以从阅读文档开始 .
这是一个链接:
How to change the launcher logo of an app in Android Studio?
16 回答
如果您有SVG图标,则可以使用此script生成您的Android图标集 .
右键单击您的项目,转到 New > Other > Android > Android Icon Set
然后按照向导上的说明进行操作
定义android应用程序的图标
https://developer.android.com/guide/topics/manifest/application-element.html
如果您的应用适用于各种设备
尺寸和格式
在mipmap或drawable文件夹中放置图标
android:icon="@drawable/icon_name"
或android:icon="@mipmap/icon_name"
developer.android.com/guide says,
about launcher icons android-developers.googleblog.com says,
Dianne Hackborn from Google (Android Framework) says ,
对于启动器图标,AndroidManifest.xml文件必须引用mipmap / location
多一点引用this
您想为设备密度加载图像,并且您将使用它"as is",而不更改其实际大小 . 在这种情况下,您应该使用 drawables ,Android将为您提供最佳的图像 .
您想为设备密度加载图像,但此图像将按比例放大或缩小 . 例如,当您想要显示更大的启动器图标,或者您有动画时,需要这样做,这会增加图像的大小 . 在这种情况下,为了确保最佳图像质量,您应该将图像放入 mipmap 文件夹中 . Android会做的是,它会尝试从更高密度的存储桶中获取图像,而不是将其放大 . 这将增加图像的清晰度(质量) .
更多你可以阅读mipmap vs drawable folders
轻松生成资产的工具
Android Asset Studio by romannurik.github
Android Asset Studio by jgilfelt.github
Image Asset Studio(from Android Studio)
Material Icon Generator.bitdroid.de
Android Material Design Icon Generator Plugin by github.com/konifar
A script to generate android assets from a SVG file
阅读更多:https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
你可以简单地安装Android工作室Martial图标插件,它的名字是请检查插件URL Material Design Icon Generator并查看此GIF以获取更多详细信息:
这主要用于创建具有所需大小的图标,并且它将直接位于其文件夹中 .
有点旧,但供将来使用:
选择图标图片复制此图片
将其粘贴到项目的
res/drawable
文件夹中打开清单文件并设置
运行程序
如果您打算在多种设备上使用您的应用程序,则应将应用程序图标放入提供的不同
res/drawable...
文件夹中 . 在每个文件夹中,您应该包含一个48dp大小的图标:drawable-ldpi
(120 dpi,低密度屏幕) - 36px x 36pxdrawable-mdpi
(160 dpi,中密度屏幕) - 48px x 48pxdrawable-hdpi
(240 dpi,高密度屏幕) - 72px x 72pxdrawable-xhdpi
(320 dpi,超高密度屏幕) - 96px x 96pxdrawable-xxhdpi
(480 dpi,超高密度屏幕) - 144px x 144pxdrawable-xxxhdpi
(640 dpi,额外超高密度屏幕) - 192px x 192px然后,您可以在
AndroidManifest.xml
文件中定义图标:我发现this tool最有用 .
上传图片 .
下载一个拉链 .
提取到您的项目中 .
Done
http://romannurik.github.io/AndroidAssetStudio/
这很简单 .
现在只需转到菜单文件→新建→图像资产 . 这将打开一个新的对话框,然后确保选中了启动器图标(默认情况下是这样),然后浏览到您的图标目录(它不必在项目资源中),然后一旦选中,请确保其他设置是你喜欢和完成的 .
现在所有分辨率都保存在各自的文件夹中,您不必担心自己复制或使用工具等 .
不要忘记透明背景的“形状 - 无” .
使用自动添加应用程序启动器图标浆纱 .
(Android studio)
转到菜单文件*→新建→图像资源→选择启动器图标→选择图像文件 .
它会自动重新调整大小 .
完成!
1-Create Your icon in Photoshop Or Coreldraw by size 256*256
2-Upload Your icon in https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
3-Set your setting on this site
4-Download the zip file automatically created by the webpage by clicking on download button
5-Extract the zip file and copy res folder to you project library
6-finally you need to set the manifest to use icon
将图像放在三个中的任何一个下的drawables文件夹中,并将其设置为这样 .
Code
您必须遵循以下步骤:
现在,您可以使用新图像运行并查看应用程序图标 .
快乐编码:) :)
转到文件 - > new-> ImageAsset .
从他们可以为您的图标创建图像资产 .
之后我们将获得mipmap中的图标图像,如hdpi,mdpi,xhdpi,xxhdpi,xxxhdpi .
现在转到AndroidManifest.xml
将您的图像放在
mipmap
文件夹中并在清单文件中设置...如同App Folder Directory :
Icon Size & Format :
您可以从阅读文档开始 .
这是一个链接:
How to change the launcher logo of an app in Android Studio?