Phonegap splashscreen orientation
When setting the splashscreen开发者_JAVA技巧 for a phonegap application, the picture gets stretched across the whole screen, even when i make a big picture with the logo in the center. Ideally I want the picture just sit in the center with a black or white background. How can I configure the behaviour of the splashscreen?
There is a better 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.
I just set the splash screen based on the current orientation on startup. Not perfect, but works. You could go further and ad on orientation change the same effect, but the chances of someone changing orientation during splash screen startup is slim.
int ot = getResources().getConfiguration().orientation;
if (ot == 2) {
super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
Log.d("Orientation", "Landscape");
}
else {
super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
Log.d("Orientation", "Portrait");
}
This is a solution but it has flaws
put your splash.png in the various drawable folders
res/drawable/splash.png (480wx800h portrait version)
res/drawable-land/splash.png (800wx480h landscape version)
known issue with this method is if the orientation changes after load it doesn't update the background... (this is true for phonegap 1.10)
精彩评论