Setup Icon & Splash Screen for Cordova

How to Setup icon for PhoneGap project

Create a new folder called res outside to www directory

Method 1 (Simple & Easy Step)

  • Create your icon file with size of (500 X 500px)
  • Create a new folder (root directory, not in www) called res for storing your icon file
  • Add this <icon src="res/icon.png"/> on your config.xml file
  • Save and compile

Method 2

  • Create an Icon Set
  • Create New Folder (root directory, not in www) called res in your project directory
  • Create Sub Directories under res folder
  • Goto config.xml file and add/edit following lines

Android

<span class="hljs-tag"><<span class="hljs-name">platform</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"android"</span>></span>
    <span class="hljs-tag"><<span class="hljs-name">icon</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/android/ldpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"ldpi"</span> /></span>
    <span class="hljs-tag"><<span class="hljs-name">icon</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/android/mdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"mdpi"</span> /></span>
    <span class="hljs-tag"><<span class="hljs-name">icon</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/android/hdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"hdpi"</span> /></span>
    <span class="hljs-tag"><<span class="hljs-name">icon</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/android/xhdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"xhdpi"</span> /></span>
<span class="hljs-tag"></<span class="hljs-name">platform</span>></span>

ios


<platform name=<span class="hljs-string">"ios"</span>>
    <icon src=<span class="hljs-string">"res/ios/icon-60@3x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"180"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"180"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-60.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"60"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"60"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-60@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"120"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"120"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-76.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"76"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"76"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-76@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"152"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"152"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-40.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"40"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"40"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-40@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"80"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"80"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"57"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"57"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"114"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"114"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-72.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"72"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"72"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-72@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"144"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"144"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-small.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"29"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"29"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-small@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"58"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"58"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-50.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"50"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"50"</span> />
    <icon src=<span class="hljs-string">"res/ios/icon-50@2x.png"</span> <span class="hljs-built_in">width</span>=<span class="hljs-string">"100"</span> <span class="hljs-built_in">height</span>=<span class="hljs-string">"100"</span> />
 </platform>

Save & Recompile your application

how to setup splash screen for PhoneGap project

In this splash screen tutorial, we’re going to learn how to set up a splash screen for PhoneGap project or apache Cordova based applications.

Follow these steps:

Step 1: Create your Cordova (PhoneGap) project

cordova create projectname
<span class="hljs-built_in">cd</span> projectname

Step 2: Add Splash Screen Plugins

cordova plugin <span class="hljs-keyword">add</span><span class="bash"> cordova-plugin-splashscreen</span>

step 3 :

Create a New folder called (res) in your root directory and save/move your splash screen images.

Step 4:

Change your config.xml file with following

<span class="hljs-tag"><<span class="hljs-name">platform</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"android"</span>></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-land-hdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"land-hdpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-land-ldpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"land-ldpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-land-mdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"land-mdpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-land-xhdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"land-xhdpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-port-hdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"port-hdpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-port-ldpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"port-ldpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-port-mdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"port-mdpi"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/android/splash-port-xhdpi.png"</span> <span class="hljs-attr">density</span>=<span class="hljs-string">"port-xhdpi"</span>/></span>
<span class="hljs-tag"></<span class="hljs-name">platform</span>></span>

<span class="hljs-tag"><<span class="hljs-name">platform</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"ios"</span>></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default~iphone.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"320"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"480"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default@2x~iphone.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"640"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"960"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-Portrait~ipad.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"768"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1024"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-Portrait@2x~ipad.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"1536"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"2048"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-Landscape~ipad.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"1024"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"768"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-Landscape@2x~ipad.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"2048"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1536"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-568h@2x~iphone.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"640"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1136"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-667h.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"750"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1334"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-736h.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"1242"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"2208"</span>/></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/ios/Default-Landscape-736h.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"2208"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1242"</span>/></span>
<span class="hljs-tag"></<span class="hljs-name">platform</span>></span>

<span class="hljs-tag"><<span class="hljs-name">platform</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"wp8"</span>></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/wp8/SplashScreenImage.jpg"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"768"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"1280"</span>/></span>
<span class="hljs-tag"></<span class="hljs-name">platform</span>></span>

<span class="hljs-tag"><<span class="hljs-name">platform</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"windows8"</span>></span>
    <span class="hljs-tag"><<span class="hljs-name">splash</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"res/screen/windows8/splashscreen.png"</span> <span class="hljs-attr">width</span>=<span class="hljs-string">"620"</span> <span class="hljs-attr">height</span>=<span class="hljs-string">"300"</span>/></span>
<span class="hljs-tag"></<span class="hljs-name">platform</span>></span>

where SplashScreenDelay is display duration in milliseconds