I’m currently working on my MAX Advanced PhoneGap Build presentation (wait, scratch that, of course I’m done already, I mean, who waits to the last minute???) and ran into an interesting issue. Using a splash screen is rather easy via the PhoneGap Build config.xml file. To test this feature, I used Placekitten.com to quickly create an image sizes 320x480. PhoneGap Build supports multiple splash screens of multiple sizes and densities, but I wanted to see how well a default splash screen would work. I dropped the kitten in my folder and added this to config.xml:
<gap:splash src=”splash.png” />
I zipped up my folder, uploaded to PGB, and everything worked fine. I noticed, though, that my splash screen only lasted for about a second. I did some digging and found that you can disable the automatic hide of the splash screen by doing this:
<preference name=”auto-hide-splash-screen” value=”false” />
In theory, that should be it, but I noticed something odd. I launched my app, and then saw this:
What the heck? At first I thought I had broken something, but then I noticed the image went away after 5 seconds. I then realized what my issue was… size.
When using the a default splash screen, PhoneGap is able to size it correctly for any device (afaik), but if you keep the splash screen around, it then reverts to the proper size for the device. In my case, I was testing on an iPhone 5. So I created a new image sized 640 by 1136 and added this to my config.xml:
<gap:splash src=”retina.png” width=”640” height=”1136” />
And it worked perfectly. You can see via this exciting YouTube video:
So I guess the take away from this is - while a default splash screen may work on multiple devices, if you are doing anything with the splash screen (like keeping it on screen longer), you want to ensure you build out properly sized images for your supported platforms. Frankly, that’s probably the best idea in general anyway.