I have a fake splash screen that pops up when my phonegap app is launched:
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 500);
I currently have 3 different splash.png files: hdpi, mdpdi and ldpi. My issue is that even in hdpi, you'll get devices that are 480 x 800 and others that are 480 x 854, and android stretches my splash image to fill the screen.
I would much rather have the image keep its aspect ratio. From what I've read, a 9-patch solution will not work with PhoneGap. If it will, please let me know how! I've got the .9.png ready to go. So the other solution I can think of is to prevent android from stretching my image. How would I do that?
Thanks!
The 9 patch solution does work for splash screens in PhoneGap :-)
Define a new drawable resource by creating a xml file, i.e. res/drawable/splash.xml with the following content:
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splashimg"
android:dither="false"/>;
Note how it references a real image 'splashimg' which should be a nine patch image (see below).
Create the nine patch images
Add the referenced nine patch images either in res/drawable or in the resolution specific folders e.g. res/drawable/splashimg.9.png
Reference the new drawable in your DroidGap extending class
public void onCreate(Bundle savedInstanceState) {
super.setIntegerProperty("splashscreen", R.drawable.splash);
}
This way you can actually make all kind of background images/effects, by using the power of drawable resources in android. See http://developer.android.com/guide/topics/resources/drawable-resource.html for more.
No need to raise a bug, there is a solution available: Simply place the following splash.xml in res/drawable (modify the android:src attribute) 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" />
Please see my Blog for a more detailed description of the set-up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With