为Android应用程序设置图标

发布于 2024-10-23 23:22:09 字数 30 浏览 0 评论 0原文

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

How can I set an icon for my Android application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(17

蓝礼 2024-10-30 23:22:09

如果您希望您的应用程序在多种设备上可用,则应将应用程序图标放入提供的不同 res/drawable... 文件夹中。在每个文件夹中,您应该包含一个 48dp 大小的图标:

  • drawable-ldpi (120 dpi,低密度屏幕) - 36px x < strong>36px
  • drawable-mdpi (160 dpi,中等密度屏幕) - 48px x 48px
  • drawable-hdpi (240 dpi,高密度屏幕) - 72px x 72px
  • drawable-xhdpi< /code> (320 dpi,超高密度屏幕) - 96px x 96px
  • drawable-xxhdpi (480 dpi,超高密度屏幕) - 144px x 144px
  • drawable-xxxhdpi (640 dpi,超高密度屏幕) - 192px x 192px

然后,您可以在 AndroidManifest.xml 文件如下:

<application android:icon="@drawable/icon_name" android:label="@string/app_name" >
.... 
</application> 

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 36px
  • drawable-mdpi (160 dpi, Medium density screen) - 48px x 48px
  • drawable-hdpi (240 dpi, High density screen) - 72px x 72px
  • drawable-xhdpi (320 dpi, Extra-high density screen) - 96px x 96px
  • drawable-xxhdpi (480 dpi, Extra-extra-high density screen) - 144px x 144px
  • drawable-xxxhdpi (640 dpi, Extra-extra-extra-high density screen) - 192px x 192px

You may then define the icon in your AndroidManifest.xml file as such:

<application android:icon="@drawable/icon_name" android:label="@string/app_name" >
.... 
</application> 
夢归不見 2024-10-30 23:22:09

添加具有自动调整大小的应用程序启动器图标。

(Android studio)

转到菜单文件* → 新建图像资源 → 选择启动器图标 → 选择图像文件。

它会自动调整大小。

完毕!

Add an application launcher icon with automatic sizing.

(Android studio)

Go to menu File* → NewImage Assets → select launcher icon → choose image file.

It will automatically re-size.

Done!

逆夏时光 2024-10-30 23:22:09

我发现这个工具最有用。

  1. 上传图像。
  2. 下载一个 zip 文件。
  3. 将其提取到您的项目中。
  4. 完成

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

I found this tool the most useful.

  1. Upload an image.
  2. Download a zip.
  3. Extract it into your project.
  4. Done

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

ぽ尐不点ル 2024-10-30 23:22:09

最好通过 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 FileNewImage 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.

Enter image description here

Don't forget "Shape - none" for a transparent background.

Please don't edit my answer without asking.

如梦 2024-10-30 23:22:09

将图像放入 mipmap 文件夹中并在清单文件中设置...
就像

 <application android:icon="@mipmap/icon" android:label="@string/app_name" >
 .... 
 </application>  

应用程序文件夹目录:

在此处输入图像描述

图标大小和大小格式:
输入图像描述这里

Put your images in mipmap folder and set in manifest file...
like as

 <application android:icon="@mipmap/icon" android:label="@string/app_name" >
 .... 
 </application>  

App Folder Directory :

enter image description here

Icon Size & Format :
enter image description here

作业与我同在 2024-10-30 23:22:09

将您的图像放在三个文件夹中的任意一个下的drawables文件夹中,然后像这样设置。

代码

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

Place your images in drawables folder under either of the three and set it like this.

Code

<application android:icon="@drawable/your_icon" >
.... 
</application>  
可是我不能没有你 2024-10-30 23:22:09

右键单击您的项目,转到新建>;其他>安卓> Android 图标集

然后按照向导上的说明进行操作

Right click your project, go to New > Other > Android > Android Icon Set

Then follow the instructions on the Wizard

最冷一天 2024-10-30 23:22:09

1-在 Photoshop 或 Coreldraw 中创建您的图标,尺寸为 256*256

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

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

3-在此网站上设置您的设置
在此处输入图像描述

4-点击下载按钮下载网页自动创建的zip文件
在此处输入图像描述

5-解压 zip 文件并将 res 文件夹复制到您的项目库
在此处输入图像描述

请注意,res 文件夹包含所有尺寸的图标

6 - 最后您需要将清单设置为使用图标

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

1-Create Your icon in Photoshop Or Coreldraw by size 256*256

note that use PNG file format if you want to have a transparent icon

2-Upload Your icon in https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html

3-Set your setting on this site
enter image description here

4-Download the zip file automatically created by the webpage by clicking on download button
enter image description here

5-Extract the zip file and copy res folder to you project library
enter image description here

note that res folder contain all size icon

6-finally you need to set the manifest to use icon

<application android:icon="@drawable/your_icon" >
.... 
</application>
小耗子 2024-10-30 23:22:09

我发现所有这些曾经是可靠答案的答案现在都有点过时了。我想有一天这将是这个答案的命运。

单击您的主项目,默认情况下大多数人都会将“app”作为其主项目名称。我喜欢具体一点,因为我还有其他项目。

[您的项目名称|应用程序]->“新建”->“图像资源”

如何在 Android Studio 中找到图像资源工具的示例

然后您将可以选择一个图像。我曾经选择过一次,但这并不是最合适的。请注意,该工具会向您显示“安全区”。

Android 示例Studio 的图像资源工具

您可以对不同的分辨率进行采样。更改名称等。默认名称为“ic_launcher”。我更喜欢用这个名字来表达,这样以后就不会混淆它也属于哪个 ic_launcher。

选择“下一步”,根据需要进行更改,最后选择“完成”。我发现该工具的其余部分是不言自明的。有关更多信息,我建议阅读更详细地描述所有这些设置的手册: Android Studio图像资产工具文档

在“完成”上,这会将文件放入预期的“res”文件夹下的相应文件夹中。
示例输出图像资源工具

接下来您要做的就是告诉项目您要使用的图标。在 AndroidManifest.xml 中执行类似以下操作(使用您在上面选择使用的自己的名称。)

     <application
     android:icon="@mipmap/pooflingers_ic_launcher">

就这样了,无论如何,从今天开始......我正在使用 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"

Example of how where to find Image Asset tool in Android Studio

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".

Example of Android Studio's Image Asset Tool

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.
Sample output of the Image Asset tool

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.)

     <application
     android:icon="@mipmap/pooflingers_ic_launcher">

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.

标点 2024-10-30 23:22:09

您可以简单地安装一个 Android studio Martial 图标插件,其名称是请检查插件 URL Material Design Icon Generator 并查看此 GIF 了解更多详细信息:

Android studio 图标插件

这主要用于创建所需尺寸的图标,它将直接位于其文件夹中。

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:

Android studio icons plugin

This is mainly for creating the icons with required sizes, and it will be located directly in its folders.

不疑不惑不回忆 2024-10-30 23:22:09

您必须按照以下步骤操作:

  • 您将看到默认图标ic_launcher.png,例如:

在此处输入图像描述

  • 您必须更改 < 中的所有图像文件夹。
    首先,您必须创建自己的徽标或选择要放置为启动器图标的图像并在此处上传 Android Asset Studio - 图标生成器 - 启动器 图标,您还可以从该链接获得所有 mipmap-xxxx 和 web_icon 集。

输入图像描述这里

  • 现在您必须复制 res 文件夹中的所有文件夹,

在此处输入图像描述

  • 现在转到 Android Studio 项目 ->右键点击res文件夹->粘贴。它会提示您目录中已存在文件'ic_launcher.png',您可以按覆盖全部。它将粘贴/替换相应文件夹中的图像。

现在您可以运行并查看带有新图像的应用程序图标。

快乐编码:) :)

You have to follow steps like:

  • You will see your default icons ic_launcher.png like:

enter image description here

  • You have to change all the images which are in mipmap-xxxx folders.
    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.

enter image description here

  • Now you have to copy all the folders which are in side of res folder,

enter image description here

  • Now go to Android Studio Project -> Right click on res folder -> Paste. It will prompt you like File 'ic_launcher.png' already exists in directory, You can press Overwrite all. It will paste/replace images in respective folder.

Now you can run and see your application icon with new image.

Happy Coding :) :)

や三分注定 2024-10-30 23:22:09
  1. 选择图标图片复制此图片
  2. 将其粘贴到项目的 res/drawable 文件夹
  3. 打开清单文件并设置

  4. 运行程序

  1. Choose icon picture copy this pic
  2. Paste it into your project's res/drawable folder
  3. Open manifest file and set

  4. Run program

樱花细雨 2024-10-30 23:22:09

如果您有 SVG 图标,则可以使用此脚本来生成 Android 图标集。

If you have an SVG icon, you can use this script to generate your android icon set.

烟酒忠诚 2024-10-30 23:22:09

在 AndroidManifest 中更改这些:

android:icon="@drawable/icon_name"
android:roundIcon="@drawable/icon_name"

In AndroidManifest change these :

android:icon="@drawable/icon_name"
android:roundIcon="@drawable/icon_name"
坏尐絯℡ 2024-10-30 23:22:09

定义 Android 应用程序的图标

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

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


如果您的应用可在多种设备上使用

您应该为所有通用屏幕密度创建单独的图标,
包括低、中、高和超高密度屏幕。这
确保您的图标能够在整个范围内正确显示
可以安装您的应用程序的设备...

在此处输入图像描述


大小和大小格式

启动器图标应为 32 位 PNG,并带有 Alpha 通道
透明度。完成的启动器图标尺寸对应于
给定的广义屏幕密度如下表所示。

输入图片此处描述


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

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

developer.android.com/guide 说< /a>,

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

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

最佳实践是将应用程序图标放置在 mipmap- 文件夹中(而不是
可绘制文件夹),因为它们的使用分辨率不同于
设备的电流密度。例如,xxxhdpi 应用程序图标可以是
用于 xxhdpi 设备的启动器。

来自 Google(Android 框架)的 Dianne Hackborn 说道

如果您正在为不同的应用程序构建不同版本的应用程序
密度,您应该了解“mipmap”资源目录。
这与“可绘制”资源完全相同,但它
创建不同的 apk 时参与密度剥离

目标。

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

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

再引用一点这个

  1. 你想要加载图像根据您的设备密度,您将“按原样”使用它,不更改其实际大小。在这种情况下,您应该使用 drawables,Android 将为您提供最合适的图像。

  2. 您想要加载适合您的设备密度的图像,但该图像将被放大或缩小。例如,当您想要显示更大的启动器图标,或者您有一个动画来增加图像的大小时,就需要这样做。在这种情况下,为了确保最佳图像质量,您应该将图像放入 mipmap 文件夹中。 Android 会尝试从密度更高的存储桶中获取图像,而不是将其放大。这将提高图像的清晰度(质量)。

有关更多信息,您可以阅读 mipmap 与可绘制文件夹


轻松生成资源的工具

  1. Android Asset Studio by romannurik.github
  2. jgilfelt.github 的 Android Asset Studio
  3. Image Asset Studio(来自 Android Studio)
  4. 材质图标生成器。 bitdroid.de
  5. github 的 Android Material Design 图标生成器插件。 com/konifar
  6. 从 SVG 文件生成 Android 资源的脚本

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

Define the icon for android application

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

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


If your app available across large range of devices

You should create separate icons for all generalized screen densities,
including low-, medium-, high-, and extra-high-density screens. This
ensures that your icons will display properly across the range of
devices on which your application can be installed...

enter image description here


Size & Format

Launcher icons should be 32-bit PNGs with an alpha channel for
transparency. The finished launcher icon dimensions corresponding to a
given generalized screen density are shown in the table below.

enter image description here


Place icon in mipmap or drawable folder

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

developer.android.com/guide says,

This attribute must be set as a reference to a drawable resource
containing the image (for example "@drawable/icon").

about launcher icons android-developers.googleblog.com says,

It’s best practice to place your app icons in mipmap- folders (not the
drawable- folders) because they are used at resolutions different from
the device’s current density. For example, an xxxhdpi app icon can be
used on the launcher for an xxhdpi device.

Dianne Hackborn from Google (Android Framework) says,

If you are building different versions of your app for different
densities, you should know about the "mipmap" resource directory.
This is exactly like "drawable" resources, except it does not
participate in density stripping
when creating the different apk
targets.

For launcher icons, the AndroidManifest.xml file must reference the mipmap/ location

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

Little bit more quoting this

  1. 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.

  2. 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

  1. Android Asset Studio by romannurik.github
  2. Android Asset Studio by jgilfelt.github
  3. Image Asset Studio(from Android Studio)
  4. Material Icon Generator.bitdroid.de
  5. Android Material Design Icon Generator Plugin by github.com/konifar
  6. A script to generate android assets from a SVG file

Read more : https://developer.android.com/guide/practices/ui_guidelines/icon_design_launcher.html

有点旧,但供将来使用:

Open Android Studio -> app/src/main/res -> Right Click -> Image Asset

A bit old, but for future use:

Open Android Studio -> app/src/main/res -> Right Click -> Image Asset
对风讲故事 2024-10-30 23:22:09

转到文件 -> 新建 -> ImageAsset。

您可以从他们中为您的图标创建图像资源。

之后我们将获得 mipmap 不同格式的图标图像,例如
hdpi、mdpi、xhdpi、xxhdpi、xxxhdpi。

现在转到 AndroidManifest.xml

<application android:icon="@mipmap/your_Icon"> ....</application>

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

<application android:icon="@mipmap/your_Icon"> ....</application>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文