Using a centered splash screen with Phonegap

Phonegap supports using a splashscreen, which is shown until your WebView has finished loading. It is the graphic alternative to using the "loadingDialog" property. In order to set a splash screen, you need to place a bitmap in your res/drawable directory and then call

super.setIntegerProperty( "splashscreen", R.drawable.splashImage );

in the onCreate(...) method of your home activity.

There is one catch, however. By default the image is stretched to the full screen size. XML Bitmap to the rescue! Simply place the following splash.xml in res/drawable and change the reference to R.drawable.splash, in the setIntegerProperty() call.

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/splashImage"
    android:gravity="center_horizontal|center_vertical" />

I have also added my answers to the Stackoverflow: Phonegap splash screen for android: not stretched question and to Stackoverflow: Phonegap splashscreen orientation