为Android应用程序设置图标
如何为我的 Android 应用程序设置图标?
How can I set an icon for my Android application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何为我的 Android 应用程序设置图标?
How can I set an icon for my Android application?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(17)
如果您希望您的应用程序在多种设备上可用,则应将应用程序图标放入提供的不同
res/drawable...
文件夹中。在每个文件夹中,您应该包含一个 48dp 大小的图标:drawable-ldpi
(120 dpi,低密度屏幕) - 36px x < strong>36pxdrawable-mdpi
(160 dpi,中等密度屏幕) - 48px x 48pxdrawable-hdpi
(240 dpi,高密度屏幕) - 72px x 72pxdrawable-xhdpi< /code> (320 dpi,超高密度屏幕) - 96px x 96px
drawable-xxhdpi
(480 dpi,超高密度屏幕) - 144px x 144pxdrawable-xxxhdpi
(640 dpi,超高密度屏幕) - 192px x 192px然后,您可以在
AndroidManifest.xml 文件如下:
If you intend on your application being available on a large range of devices, you should place your application icon into the different
res/drawable...
folders provided. In each of these folders, you should include a 48dp sized icon:drawable-ldpi
(120 dpi, Low density screen) - 36px x 36pxdrawable-mdpi
(160 dpi, Medium density screen) - 48px x 48pxdrawable-hdpi
(240 dpi, High density screen) - 72px x 72pxdrawable-xhdpi
(320 dpi, Extra-high density screen) - 96px x 96pxdrawable-xxhdpi
(480 dpi, Extra-extra-high density screen) - 144px x 144pxdrawable-xxxhdpi
(640 dpi, Extra-extra-extra-high density screen) - 192px x 192pxYou may then define the icon in your
AndroidManifest.xml
file as such:添加具有自动调整大小的应用程序启动器图标。
(Android studio)
转到菜单文件* → 新建 → 图像资源 → 选择启动器图标 → 选择图像文件。
它会自动调整大小。
完毕!
Add an application launcher icon with automatic sizing.
(Android studio)
Go to menu File* → New → Image Assets → select launcher icon → choose image file.
It will automatically re-size.
Done!
我发现这个工具最有用。
https://romannurik.github.io/ AndroidAssetStudio/
I found this tool the most useful.
https://romannurik.github.io/AndroidAssetStudio/
最好通过 Android Studio 而不是文件浏览器来执行此操作,因为它会使用正确的分辨率更新所有图标文件。
为此,请转到菜单文件 → 新建 → 图像资源。这将打开一个新对话框,然后确保选择启动器图标(默认情况下),然后浏览到图标的目录(它不必位于项目资源中),然后选择后确保其他设置符合您的喜好并点击完成。
现在所有分辨率都保存到各自的文件夹中,您不必担心自己复制或使用工具等。
不要忘记透明背景的“形状 - 无”。
请不要在未经询问的情况下编辑我的答案。
It's better to do this through Android Studio rather than the file browser as it updates all icon files with the correct resolution for each.
To do so go to menu File → New → Image Asset. This will open a new dialogue and then make sure Launcher Icons is selected (Which it is by default) and then browse to the directory of your icon (it doesn't have to be in the project resources) and then once selected make sure other settings are to your liking and hit done.
Now all resolutions are saved into their respective folders, and you don't have to worry about copying it yourself or using tools, etc.
Don't forget "Shape - none" for a transparent background.
Please don't edit my answer without asking.
将图像放入
mipmap
文件夹中并在清单文件中设置...就像
应用程序文件夹目录:
图标大小和大小格式:
Put your images in
mipmap
folder and set in manifest file...like as
App Folder Directory :
Icon Size & Format :
将您的图像放在三个文件夹中的任意一个下的drawables文件夹中,然后像这样设置。
代码
Place your images in drawables folder under either of the three and set it like this.
Code
右键单击您的项目,转到新建>;其他>安卓> Android 图标集
然后按照向导上的说明进行操作
Right click your project, go to New > Other > Android > Android Icon Set
Then follow the instructions on the Wizard
1-在 Photoshop 或 Coreldraw 中创建您的图标,尺寸为 256*256
2-上传您的图标 https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
3-在此网站上设置您的设置
4-点击下载按钮下载网页自动创建的zip文件
5-解压 zip 文件并将 res 文件夹复制到您的项目库
6 - 最后您需要将清单设置为使用图标
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
我发现所有这些曾经是可靠答案的答案现在都有点过时了。我想有一天这将是这个答案的命运。
单击您的主项目,默认情况下大多数人都会将“app”作为其主项目名称。我喜欢具体一点,因为我还有其他项目。
[您的项目名称|应用程序]->“新建”->“图像资源”
然后您将可以选择一个图像。我曾经选择过一次,但这并不是最合适的。请注意,该工具会向您显示“安全区”。
您可以对不同的分辨率进行采样。更改名称等。默认名称为“ic_launcher”。我更喜欢用这个名字来表达,这样以后就不会混淆它也属于哪个 ic_launcher。
选择“下一步”,根据需要进行更改,最后选择“完成”。我发现该工具的其余部分是不言自明的。有关更多信息,我建议阅读更详细地描述所有这些设置的手册: Android Studio图像资产工具文档
在“完成”上,这会将文件放入预期的“res”文件夹下的相应文件夹中。
接下来您要做的就是告诉项目您要使用的图标。在 AndroidManifest.xml 中执行类似以下操作(使用您在上面选择使用的自己的名称。)
就这样了,无论如何,从今天开始......我正在使用 Android Studio v4.2.1 当这些步骤完成时请告诉我的日期。
I found all these answers that used to be solid answers to be a bit dated now. I reckon this will be the fate of this answer someday.
Click on your main project, most people would have "app" as their main project name by default. I like to be specific since I have other projects as well.
[your project name|app]->"New"->"Image Asset"
Then you will get to pick an image. I chose once that wasn't the greatest fit. Notice the tool shows you the "safe zone".
You can sample the different resolutions. Change the name, etc. The default name is "ic_launcher". I prefer to be expressive with the name so there is no confusion later which ic_launcher this belongs too.
Choose "Next", make changes if you need to, and ultimately "Finish". I found the rest of the tool to be self explanatory. For more info I suggest reading the manual that describes all these settings in more detail: Android Studio Image Asset Tool Documentation
On "Finish" this will put the files into the respective folders under the expected "res" folder.
The next thing you have to do is have to tell the project that's the icon you want to use. Inside the AndroidManifest.xml do something like the following (using your own name you chose to use above.)
That's pretty much it, as of today anyway... I am using Android Studio v4.2.1 Let me know when these steps become out of date.
您可以简单地安装一个 Android studio Martial 图标插件,其名称是请检查插件 URL Material Design Icon Generator 并查看此 GIF 了解更多详细信息:
这主要用于创建所需尺寸的图标,它将直接位于其文件夹中。
You can simply install an Android studio Martial icons plugin its name is please check plugin URL Material Design Icon Generator and check this GIF for more details:
This is mainly for creating the icons with required sizes, and it will be located directly in its folders.
您必须按照以下步骤操作:
ic_launcher.png
,例如:首先,您必须创建自己的徽标或选择要放置为启动器图标的图像并在此处上传 Android Asset Studio - 图标生成器 - 启动器 图标,您还可以从该链接获得所有 mipmap-xxxx 和 web_icon 集。
现在您可以运行并查看带有新图像的应用程序图标。
快乐编码:) :)
You have to follow steps like:
ic_launcher.png
like:First of you have to create your own logo or pick up image that you want to place as icon of launcher and upload here Android Asset Studio - Icon Generator - Launcher icons, You will get all the set of mipmap-xxxx and web_icon also from that link.
Now you can run and see your application icon with new image.
Happy Coding :) :)
res/drawable
文件夹打开清单文件并设置
运行程序
res/drawable
folderOpen manifest file and set
Run program
如果您有 SVG 图标,则可以使用此脚本来生成 Android 图标集。
If you have an SVG icon, you can use this script to generate your android icon set.
在 AndroidManifest 中更改这些:
In AndroidManifest change these :
定义 Android 应用程序的图标
https://developer.android .com/guide/topics/manifest/application-element.html
如果您的应用可在多种设备上使用
大小和大小格式
将图标放在 mipmap 或可绘制文件夹中
android:icon="@drawable/icon_name"
或android:icon="@mipmap/icon_name"
developer.android.com/guide 说< /a>,
关于启动器图标 android-developers.googleblog.com 说,
来自 Google(Android 框架)的 Dianne Hackborn 说道,
对于启动器图标,AndroidManifest.xml 文件必须引用mipmap/位置
再引用一点这个
你想要加载图像根据您的设备密度,您将“按原样”使用它,不更改其实际大小。在这种情况下,您应该使用 drawables,Android 将为您提供最合适的图像。
您想要加载适合您的设备密度的图像,但该图像将被放大或缩小。例如,当您想要显示更大的启动器图标,或者您有一个动画来增加图像的大小时,就需要这样做。在这种情况下,为了确保最佳图像质量,您应该将图像放入 mipmap 文件夹中。 Android 会尝试从密度更高的存储桶中获取图像,而不是将其放大。这将提高图像的清晰度(质量)。
有关更多信息,您可以阅读 mipmap 与可绘制文件夹
轻松生成资源的工具
阅读更多: https://developer.android.com/guide/practices/ui_guidelines /icon_design_launcher.html
Define the icon for android application
https://developer.android.com/guide/topics/manifest/application-element.html
If your app available across large range of devices
Size & Format
Place icon in mipmap or drawable folder
android:icon="@drawable/icon_name"
orandroid:icon="@mipmap/icon_name"
developer.android.com/guide says,
about launcher icons android-developers.googleblog.com says,
Dianne Hackborn from Google (Android Framework) says,
For launcher icons, the AndroidManifest.xml file must reference the mipmap/ location
Little bit more quoting this
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.
Fore more you can read mipmap vs drawable folders
Tools to easily generate assets
Read more : https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html
有点旧,但供将来使用:
A bit old, but for future use:
转到文件 -> 新建 -> ImageAsset。
您可以从他们中为您的图标创建图像资源。
之后我们将获得 mipmap 不同格式的图标图像,例如
hdpi、mdpi、xhdpi、xxhdpi、xxxhdpi。
现在转到 AndroidManifest.xml
Goto File->new->ImageAsset.
From their you can create Image Assets for your icon.
After that we will get icon image in mipmap different formats like
hdpi,mdpi,xhdpi,xxhdpi,xxxhdpi.
Now goto AndroidManifest.xml