如何在 Android Studio 中导入自定义图标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22370237/
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 do I import a custom made icon in Android Studio?
提问by Azurespot
I made my own icon for my Android app, but I am a beginner in Android Studio, and it is not importing into my already existing Android Studio project.
我为我的 Android 应用程序制作了自己的图标,但我是 Android Studio 的初学者,它没有导入到我现有的 Android Studio 项目中。
I read to just use the Android Launcher Icon Generatorfrom Android Asset Studio, which then creates a zip file for you, which should be placed inside your project res folder. I basically replaced the old res folder with the new one, and I checked and all the new icons are in their right folders, i.e. drawable-hdpi, drawable-mdpi, etc within my project directory, but they are not in the res folder of my project pane of Android Studio.
我读到只使用Android Asset Studio 中的Android Launcher Icon Generator,然后它会为您创建一个 zip 文件,该文件应该放在您的项目 res 文件夹中。我基本上用新的文件夹替换了旧的 res 文件夹,我检查了所有新图标都在我的项目目录中的正确文件夹中,即 drawable-hdpi、drawable-mdpi 等,但它们不在 res 文件夹中我的 Android Studio 项目窗格。
However, I restarted Android Studio, and it did not refresh to show these new imports. When I run my project, it still shows the old standard ic-launcher.png files.
但是,我重新启动了 Android Studio,并没有刷新以显示这些新导入。当我运行我的项目时,它仍然显示旧的标准 ic-launcher.png 文件。
回答by YesItsMe
right click on resfolder, selecting New> Image Asset. browse image file, should do the job for you
右键单击res文件夹,选择New> Image Asset。浏览图像文件,应该为你做这项工作
回答by user-qazimodo
You can change the icon by going in the AndroidManifest.xml of your project, look for the Application tab below the status bar(if that's what it is called) then look for the Icon label/text click the Browse... button beside the textarea then it will prompt a Resource Chooser dialog. Click the Create New Icon; it will show Create Asset Set dialog, you can proceed to the next dialog by clicking the Next button, configure the icon set by selecting whether it is image or text or clipart that you want for the icon.
您可以通过进入项目的 AndroidManifest.xml 来更改图标,查找状态栏下方的应用程序选项卡(如果它是这样调用的),然后查找图标标签/文本单击浏览...按钮旁边的textarea 然后它会提示一个资源选择器对话框。单击创建新图标;它将显示创建资产集对话框,您可以通过单击下一步按钮进入下一个对话框,通过选择您想要的图标是图像还是文本或剪贴画来配置图标集。
When you click the image button, it will the path of your old image, you can select your new image by clicking Browse -> directory to your new image. Select your desired scaling, shape and background for the other fields or settings. Click Finish, it will prompt that the file already exists and will change all the ic_launcher.png in your /res folder, just click Yes to All. Then it's now updated to your new image.
当您单击图像按钮时,它将显示旧图像的路径,您可以通过单击浏览 -> 新图像的目录来选择新图像。为其他字段或设置选择所需的缩放比例、形状和背景。点击Finish,它会提示文件已经存在,并且会改变你/res文件夹中的所有ic_launcher.png,只需点击Yes to All即可。然后它现在更新为您的新图像。
回答by Moshii
Very easy. Just copy your generated icon paste it in drawable folder as follows.
好简单。只需复制您生成的图标并将其粘贴到可绘制文件夹中,如下所示。
Suppose generated icons are in those folders:
假设生成的图标在这些文件夹中:
Then go to every folder, copy the icon and paste in drawable folder. Android studio will ask to select a folder, paste it to corresponding folder.
然后转到每个文件夹,复制图标并粘贴到可绘制文件夹中。Android studio 会要求选择一个文件夹,粘贴到对应的文件夹中。
Don't worry for first icon, after pasting second icon, android studio automatically create folder structure.
不用担心第一个图标,粘贴第二个图标后,android studio 会自动创建文件夹结构。
I know there are other proper ways to import custom icon, but this easy and not thinkable way
我知道还有其他正确的方法可以导入自定义图标,但这种简单且不可想象的方法