Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Cordova application icon?

Tags:

cordova

I designed an icon in 4 standard sizes : hdpi, ldpi, mdpi and xhdpi.

I put these icons into :

  • "\platforms\android\res\drawable-hdpi"
  • "\platforms\android\res\drawable-ldpi"
  • "\platforms\android\res\drawable-mdpi"
  • "\platforms\android\res\drawable-xhdpi" folder.

The names of each icon is "icon.jpg".

How can I use these icons as my application icon?

like image 303
Behzad Azizan Avatar asked Jun 11 '15 22:06

Behzad Azizan


2 Answers

The answer may vary based on your version of Cordova, but as of Cordova 3.5.0, this is the way of adding icons to your project. As mentioned in my comment, see the official docs for the source.

First create a folder for your icons to live. This will vary depending on your platform, since we are dealing with Android in your case, an assets folder will do nicely. It is easiest to create this in the project root (i.e. with the www/ hooks/ folders, config.xml file etc.)

While this won't impact you, it might be good to note. There is a small BlackBerry quirk regarding icons and splash screens. For BB10 you must place your assets folder in the www/ directory.

Drop your icons in there and add something along these lines to your config.xml file, where the pngs correspond to your icons:

<platform name="android">    
    <icon src="assets/mdpi.png" density="mdpi" />
    <icon src="assets/ldpi.png" density="ldpi" />
    <icon src="assets/hdpi.png" density="hdpi" />
    <icon src="assets/xdpi.png" density="xhdpi" />
    <icon src="assets/xxdpi.png" density="xxhdpi" />
</platform>

Lastly, you can verify these worked after your build by checking the platforms\android\res\drawable- folders. They will contain an icon.png file that was copied across from your source directory during the build.

like image 133
laughingpine Avatar answered Oct 04 '22 19:10

laughingpine


Add a folder res in app and create folder in it icons/android and save images there

<platform name="android">
    <icon src="res/icons/android/icon-36-ldpi.png" density="ldpi"/>
    <icon src="res/icons/android/icon-48-mdpi.png" density="mdpi"/>
    <icon src="res/icons/android/icon-72-hdpi.png" density="hdpi"/>
    <icon src="res/icons/android/icon-96-xhdpi.png" density="xhdpi"/>
</platform>
like image 36
tayyab islam Avatar answered Oct 04 '22 21:10

tayyab islam