How to change the icon of your Android app

This is just a small follow-up post to The easiest way to create nice icons for Android apps.

Say, if you follow that guide, and have made an icon to represent your app, how do you use it?

If you have one icon image, or three icon images (one for each screen density, ldpi, mdpi and hdpi, like in the guide), you put your icon files in the res/drawable folder where they belong.

Depending on what API level you are creating your Android application for, in your “res” folder you either have one folder called “drawable” or four folders named:

  • /drawable-ldpi
  • /drawable-mdpi
  • /drawable-hdpi
  • /drawable-xhdpi

For application launcher icons, the sizes are:

Low densityldpi120 dpi36×36 px
Medium densitymdpi160 dpi48×48 px
High densityhdpi240 dpi72×72 px
Extra High densityxhdpi320 dpi96×96 px
 

When you have put your icon in the folder/folders, open up your AndroidManifest.xml file and choose to view it as XML.

For a new Android application, the AndroidManifest.xml file will look like this:

<?xml version="1.0" encoding="utf-8"?>  
<manifest xmlns:android="http://schemas.android.com/apk/res/android"  
      package="test.application"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".YourAppName"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>  

And on line 6 you can see the attribute that specifies your applications icon:

android:icon="@drawable/icon"

The /icon refers to the default icon.png file in your drawable folder (or the drawable-ldpi/mdpi/hdpi/xhdpi folders), so just substitute “icon” with the name of your icon file, you will change the icon of your app.

comments powered by Disqus