如何在 Android Studio 中更改应用程序的启动器徽标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26615889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change the launcher logo of an app in Android Studio?
提问by user3535901
I was wondering how to change the launcher icon in Android Studio. I would be very grateful for any advice you can give me.
我想知道如何更改 Android Studio 中的启动器图标。如果您能给我任何建议,我将不胜感激。
回答by Coder X
Here is another solution which I feel is more sensible for those working on Android Studio:
这是另一个我觉得对那些在 Android Studio 上工作的人更明智的解决方案:
- Expand the project root folder in the Project View
- Right Clickon the appfolder
- In the Context Menugo to New->Image Asset
- In the pop up that appears select the the new logo you would like to have(image/clip art/text).
- If you were selecting the image radio button (as is the default choice), if you clicked on the 3-buttons to show the path tree to locate your .png image file, most probably you might not be seeing it, so drag it from the Windows Explorer (if Windows) and drop it in the tree, and it will appear and ready for being selected.
- 在项目视图中展开项目根文件夹
- 右击该应用程序文件夹
- 在上下文菜单中,转到New->Image Asset
- 在出现的弹出窗口中选择您想要的新徽标(图像/剪贴画/文本)。
- 如果您选择了图像单选按钮(这是默认选择),如果您单击 3 个按钮以显示路径树来定位您的 .png 图像文件,则很可能您可能看不到它,因此将它从Windows 资源管理器(如果是 Windows)并将其放在树中,它将出现并准备好被选中。
That is it! You have a new logo for you app now.
这就对了!现在,您的应用程序有了新徽标。
回答by Bryan Herbst
Look in the application's AndroidManifest.xml file for the <application>
tag.
在应用程序的 AndroidManifest.xml 文件中查找<application>
标记。
This application tag has an android:icon
attribute, which is usually @drawable/ic_launcher
.
The value here is the name of the launcher icon file. If the value is @drawable/ic_launcher
, then the name of the icon is ic_launcher.png
.
这个应用程序标签有一个android:icon
属性,通常是@drawable/ic_launcher
。这里的值是启动器图标文件的名称。如果值为@drawable/ic_launcher
,则图标的名称为ic_launcher.png
。
Find this icon in your resource folders (res/mipmap-mdpi
, res/mipmap-hdpi
, etc.) and replace it.
查找您的资源文件夹这个图标(res/mipmap-mdpi
,res/mipmap-hdpi
等)和替换它。
A note on mipmap resources: If your launcher icon is currently in drawable folders such as res/drawable-hdpi
, you should move them to the mipmap equivalents (e.g. res/mipmap-hdpi
). Android will better preserve the resolution of drawables in the mipmap folderfor display in launcher applications.
关于 mipmap 资源的说明:如果您的启动器图标当前位于可绘制文件夹中,例如res/drawable-hdpi
,您应该将它们移动到 mipmap 等效项(例如res/mipmap-hdpi
)。Android 将更好地保留 mipmap 文件夹中可绘制对象的分辨率,以便在启动器应用程序中显示。
Android Studio note: If you are using Android Studio you can let studio place the drawables in the correct place for you. Simply right click on your application module and click New-> Image Asset.
Android Studio 注意:如果您使用的是 Android Studio,您可以让 Studio 为您将可绘制对象放置在正确的位置。只需右键单击您的应用程序模块,然后单击New-> Image Asset。
For the icon type select either "Launcher Icons (Legacy Only)"for flat PNG files or "Launcher Icons (Adaptive and Legacy)"if you also want to generate an adaptive iconfor API 26+ devices.
对于图标类型,如果您还想为 API 26+ 设备生成自适应图标,请为平面 PNG 文件选择“启动器图标(仅限旧版)”或“启动器图标(自适应和旧版)”。
回答by Mtn Pete
Here are my steps for the task:
以下是我的任务步骤:
- Create PNGimage file of size 512x512pixels
- In Android Studio, in project view, highlighta mipmap directory
- In menu, goto File>New>Image Asset
- ClickImage Buttonin Asset typebutton row
- Clickon 3 Dot Boxat right of Path Box.
- Dragimage to source asset box
- ClickNext(Note: Existing launcher fileswill be overwritten)
- ClickFinish
- 创建大小为512x512像素的PNG图像文件
- 在Android Studio的项目视图中,突出显示一个mipmap 目录
- 在菜单中,进入到文件>新建>图像资产
- 点击图像按钮在资产类型按钮行
- 点击在3点框右侧的路径框。
- 将图像拖动到源资产框
- 单击下一步(注意:现有的启动器文件将被覆盖)
- 单击完成
回答by Robbie
To quickly create a new set of icons and change the launcher icon in Android Studio, you can:
要在 Android Studio 中快速创建一组新图标并更改启动器图标,您可以:
Use this tool: https://romannurik.github.io/AndroidAssetStudio/icons-launcher.htmlto upload your preferred image or icon (your source file). The tool then automatically creates a set of icons in all the different resolutions for the ic_launcher.png.
Download the zip-file created by the tool, extract everything (which will create a folder structure for all the different resolutions) and then replace all the icons inside your project res folder: <AndroidStudioProjectPath>\app\src\main\res
使用此工具:https: //romannurik.github.io/AndroidAssetStudio/icons-launcher.html上传您喜欢的图片或图标(您的源文件)。然后,该工具会自动为 ic_launcher.png 创建一组具有所有不同分辨率的图标。
下载由该工具创建的 zip 文件,解压缩所有内容(这将为所有不同的分辨率创建一个文件夹结构),然后替换项目 res 文件夹中的所有图标:<AndroidStudioProjectPath>\app\src\main\res
回答by korubilli krishna chaitanya
go to AndroidManifest.xml and change the android:icon="@mipmap/ic_launcher" to android:icon="@mipmap/(your image name)"
suppose you have a image named telugu and you want it to be set as your app icon then change android:icon="@mipmap/telugu" and you have to copy and paste your image into mipmap folder thats it its so simple as i said
转到 AndroidManifest.xml 并将 android:icon="@mipmap/ic_launcher" 更改为 android:icon="@mipmap/(your image name)" 假设您有一个名为 telugu 的图像并且您希望将其设置为您的应用程序图标然后更改 android:icon="@mipmap/telugu" 并且您必须将图像复制并粘贴到 mipmap 文件夹中,这就像我说的那样简单
回答by berserk
In the manifest file, under the tag, there will be a similar line:
在清单文件中,标签下,会有类似的一行:
android:icon="drawable_resource_path"
Place the launcher icon you want in drawable folder and write its resource path.
将你想要的启动器图标放在 drawable 文件夹中并写下它的资源路径。
回答by Md. Rejaul Karim
Try this process, this may help you.
试试这个过程,这可能对你有帮助。
- Create PNG image file of size 512x512 pixels
- In menu, go to File -> New -> Image Asset
- Select Image option in Asset type options
- Click on Directory Box at right.
- Drag image to source asset box
- Click Next (Note: Existing launcher files will be overwritten)
- Click Finish
- 创建大小为 512x512 像素的 PNG 图像文件
- 在菜单中,转到 File -> New -> Image Asset
- 在资产类型选项中选择图像选项
- 单击右侧的目录框。
- 将图像拖动到源资产框
- 单击下一步(注意:现有的启动器文件将被覆盖)
- 单击完成
***** NB: Icon type should be Launcher Icons (Adaptive and Legacy) *****
***** 注意:图标类型应该是启动器图标(自适应和传统) *****
回答by Palak Jain
Go to AndroidManifest.xml
In the tag, look for android:icontag.
Copy and paste your icon in drawable folder(available in res folder of your project).
Set the value of android:icontag as
android:icon="@drawable/youriconname"
转到 AndroidManifest.xml
在标签中,查找android:icon标签。
将您的图标复制并粘贴到 drawable 文件夹中(在项目的 res 文件夹中可用)。
将android:icon标签的值设置为
android:icon="@drawable/你的图标名称"
Voila! you are done. Save the changes and test.
瞧!你完成了。保存更改并测试。
回答by sameer tzar
We can replace the code in the AndroidManifest file in the application tag
我们可以将AndroidManifest文件中应用标签中的代码替换
android:icon="@drawable/logo"
回答by Linoie
Go to your project folder\app\src\main\res\mipmap-mdpi\ic_launcher.png
转到您的项目文件夹\app\src\main\res\mipmap-mdpi\ic_launcher.png
You will see 5 mipmap folders. Replace the icon inside of the each mipmap folder, with the icon you want.
您将看到 5 个 mipmap 文件夹。用您想要的图标替换每个 mipmap 文件夹内的图标。