从 Android Studio 中的图像重新构建或重新生成“ ic_launcher.png”

当第一次创建一个新项目时,该对话框允许您指向 一些外部的。 PNG 文件,然后当该对话框完成, 它生成4个不同像素大小的图像,用作 发射器图标。

我的问题是: 所以,如果一个人已经有一个现有的项目 是否有地方告诉工作室重新生成 4新的这样的文件,只是重新指向其他地方,一些 巴布亚新几内亚?

我突然想到我可以开始一个新的项目,然后 手动复制到目前为止开发的所有其他文件,例如 的. JAVA 和. XML 文件等,但似乎有很多 工作(我希望不必要)。

237662 次浏览

No, but you can do this almost as easily.

Go here:

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

Build your icons using that page, and then download the zip package. Unzip it into the right directory and it'll overwrite all the drawable-*/ic_launcher.png correctly.

When making an Android app in eclipse, just right-click on the res folder, click New -> Other, and select Android Icon Set under Android.

This allows you to make more icons (or replace any existing ones) easily.

For Android Studio 0.4.0 and later, click "File > New > Image Asset".

Just in case anyone else visits this post I thought I'd describe what I did.

  1. Right click on res folder > New image asset

  2. browser to the icon. Click next

  3. By default the icon goes to src/debug/res- keep this

  4. In the project hierarchy, browse to src/debug/res and copy the files from the drawable* directories to the same directories in src/main and src/main

  5. copy the src/debug/res/icon_name.png to the src/main and src/release directories

On Android Studio 0.5.8 I managed to change my icon set by right clicking on the 'res' folder and selecting New > Image Asset. This brings you to the icon screen you are presented when creating the application, here after you change the icon it confirms that it will replace all the icons. Confirm and done.

Use the website mentioned in previous posts to create the icons:http://android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html Unzip folder and Go into you file explorer on (windows or mac) find AndroidStudioProjects > "app name" > app > src > main (replace the web one here)> res (replace the rest with the one from the unzipped folder the you already downloaded)

*Close android studio so that you can make changes and when android studio is opened again the changes will appear

In Android studio 0.8 and after Right click on app folder then New > Image Asset

Browse for best resolution image you have in "Image file" field

hit Next The rest will be generated

I can confirm that in Android Studio 1.x (here AS) on Windows also the right sequence is:

  • File -> New
  • AS opens a list where you must click on Image Asset
  • AS opens a dialog where the app\src\main\res Directory Structure is automatically selected (the right choice)
  • Clicking on the OK button, AS opens the Asset Studio dialog where you can find all the tools and options we had on the past Eclipse ADT

This can be done absolutely in any moments after creation of the project.

Android Studio warns you that it will overwrite the current ic_launcer, but this is exactly what we expect to do.

Put the desired launcher image (.png) in drawable folder.

In AndroidManifest.xml, add

android:icon="@drawable/your_img_name"

under application tag.

  1. File >In androidStudio Open your application(your project)

  2. Go to res folder and then right click on that folder select the new tab in that go to image asset tab you will get asset studio display page .

  3. Browse(select) the icon that you want get as app icon(no need to change the drawble folder) .

  4. And then click next tab and finish.

  5. your new icon will displayed in the app.

the answers above were confusing to me. Here is what i did:

  • File ->new Image Asset
  • the first field "Asset type" must be launcher icons. browse to the file you want as icon, select it and android studio will show you in the same window what it will look like under different resolutions.

  • choose a different name for it, click next. Now the icon set for all those hdpi, xhdpi, mdpi will be in corresponding mipmap folders

  • finally, most importantly go to your manifest file and change "android:icon" to the name of your new icon image.

You can create an icon using this website https://romannurik.github.io/AndroidAssetStudio/index.html.

Download the icon, go to File Explorer - where your projects are saved, the default path is C:\Users\Your Name\AndroidStudioProjects\Project Name\app\src\main\res\

and copy the folders you downloaded to the res folder.

Click "File > New > Image Asset"

Asset Type -> Choose -> Image

Browse your image

Set the other properties

Press Next

You will see the 4 different pixel-sizes of your images for use as a launcher-icon

Press Finish !

For Android 3+:

  • In the Project window, select the Android view.

  • Right-click the res folder and select New > Image Asset.

  • If your app supports Android 8.0, create adaptive and legacy launcher icons.

  • If your app supports versions no higher than Android 7.1, create a legacy launcher icon only.

  • In the Icon Type field, select Launcher Icons (Legacy Only) .

  • Select an Asset Type, and then specify the asset in the field underneath.

This is how I solved by creating an ic_launcher from a PNG image.

  1. I converted a PNG image into SVG image by using this website https://image.online-convert.com/convert-to-svg.

  2. I used the converted SVG image and converted it into a Vector Asset in Android Studio by, File > New > Vector Asset. This converted the SVG image into an XML file.

  3. I created the ic_launcher image by creating a new Image Asset in Android Studio by, File > New > Image Asset. This created an ic_launcher in a square, round and an Adaptive icon from the XML file.

Note: At the time of writing I faced issues with the SVG image exported from Adobe XD. So I had to use the online converter. Adobe XD does not have xml export feature.