Set icon for Android application
Asked Answered
D

17

670

How can I set an icon for my Android application?

Domain answered 18/3, 2011 at 10:23 Comment(3)
NOTE, for 2016, simply select "New Image Asset" (find it usually via: right-click on eg. the "mipmap" res item) and then just use the wizard. Start with one large image and it scales it for you. See answer by @Justice below.Mccray
Important tip for transparent BG: https://mcmap.net/q/67926/-android-studio-image-asset-launcher-icon-background-colorMccray
I'm suggestion (WebApp) https://android-material-icon-generator.bitdroid.deCottontail
L
737

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> 
Lousy answered 30/5, 2012 at 14:6 Comment(9)
BTW you can use Inkscape to generate png from SVG. With something like: inkscape %logo_file% -e %output_file% %WIDTH% %HEIGHT% --export-background-opacity=0.0Andes
You can use a single large icon, though you'll have no control over how the algorithm changes its final appearance. This question has been answered here: #6695913Lousy
What should the extension be? .png? .ico?Baerman
imagine how 512 x 512 will be displayed as 36 x 36? program will pick some pixels from 512 x 512, maybe somehow mix them and display as 36 x 36. There sure will be quantization error, e.g., en.wikipedia.org/wiki/Aliasing. So sure the 36 x 36 image will not be pixel perfect.Cantilever
@LiamGeorgeBetsworth where exactly did you find those sizes?Leicester
@Leicester developer.android.com/design/style/iconography.html - "So, to create an icon for different densities, you should follow the 2:3:4:6:8 scaling ratio between the five primary densities (medium, high, x-high, xx-high, and xxx-high respectively). For example, consider that the size for a launcher icon is specified to be 48x48 dp. This means the baseline (MDPI) asset is 48x48 px, and the high-density(HDPI) asset should be 1.5x the baseline at 72x72 px, and the x-high density (XHDPI) asset should be 2x the baseline at 96x96 px, and so on."Lousy
See my comment #17050232 to let Gradle generate the resource files for you.Anesthesia
See my answer below where you only need to set one image and Android Studio handles the scaling for you.Sonata
For anyone reading this comment - please refer to Arshid's answer belowSuppletion
I
358

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!

Irregularity answered 17/12, 2015 at 10:11 Comment(8)
i don't understand why this isn't the best answer. can someone explain? all the folders and scaled images are created for meCondor
This explains how to create folders and scaled images. It does not explain how to set any of them to be the app's icon.Estebanesteem
Sorry, my comment is about why I think it is not the best answer. It is a very good answer and helped my solve my icon problem.Estebanesteem
I understand that it will automatically resize but what size do you usually supply? 512x512?Darrelldarrelle
This is the fastest way and supported right out of the box. Thanks a lot for pointing this out, enjoy some bounty.Spiroid
In today's Android Studio I found this menu by right clicking in the browse pane on the left.Zak
medium.com/@ujikit/…Photoelectron
This is the fastest and most reliable way. I don't know why or how the accepted answer got 700+ votes...Suppletion
O
216

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/

Orv answered 7/8, 2012 at 12:19 Comment(4)
This is a super easy way to do it! My steps were: 1) Create 144x144 image from illustrator file 2) Upload the file 3) Play with settings on website for padding/etc 4) Copy "res" file from .zip from site, paste it in IntelliJ and select "Overwrite Files"Phira
Do the images go into mitmpa or drawables?Disband
I don`t understand what to do with this zip :cFair
This doesn't give it in ldpiBurgett
S
80

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.

Sonata answered 26/3, 2016 at 9:11 Comment(3)
For newer versions of android studio, this is the best answer, +1 from meDexamethasone
Updated for 2018, should be firstStodge
This is the best answer, because Android Studio will generate all the right assets with the right names. You can start with a single image asset rather than having to manually generate different assets sizes and then trying to figure out where they go in the latest version of Android Studio.Bisitun
C
42

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

Clipboard answered 18/3, 2011 at 10:37 Comment(0)
R
33

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

Code

<application android:icon="@drawable/your_icon" >
.... 
</application>  
Rennin answered 18/3, 2011 at 10:28 Comment(1)
which folder which file....Dd
T
21

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

Then follow the instructions on the Wizard

Thaothapa answered 27/3, 2013 at 15:6 Comment(2)
That option doesn't exist on Android Studio.Philae
I had to click on a file in the project to expand the breadcrumbs at the top. Then there were different options available when right clicking the project. New > Image AssetsToni
A
20

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>
Ackerley answered 18/3, 2011 at 10:23 Comment(0)
T
14

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.

Toehold answered 24/6, 2021 at 6:13 Comment(0)
N
13

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.

Nava answered 21/2, 2017 at 17:0 Comment(0)
S
7

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

Seagirt answered 15/3, 2016 at 14:1 Comment(1)
I prefer your answer... Thx for helpSteverson
A
6
  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

Affranchise answered 2/11, 2011 at 10:57 Comment(0)
M
5

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

Moidore answered 21/8, 2014 at 7:52 Comment(0)
E
5

In AndroidManifest change these :

android:icon="@drawable/icon_name"
android:roundIcon="@drawable/icon_name"
Estevan answered 5/1, 2020 at 13:17 Comment(1)
I liked it, straight to the fact. ThxKuo
E
4

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

Enfeoff answered 21/2, 2017 at 14:41 Comment(0)
L
3

A bit old, but for future use:

Open Android Studio -> app/src/main/res -> Right Click -> Image Asset
Lashonlashond answered 9/11, 2015 at 0:46 Comment(0)
S
0

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>
Shaniceshanie answered 12/6, 2017 at 13:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.