What should I enter to config.xml
or what should I do in general, to have PhoneGap Build application\'s splash screen displayed correctly on Android device in lands
I'm not using PhoneGap Build, but I managed to fix this in a basic PhoneGap Android app.
Let's say you have two different splash images - a landscape and a portrait version - and you want both of them to stretch to fill the available screen area.
Put one in drawable
and the other in drawable-land
. (Or drawable-land-hdpi
, drawable-land-xhdpi
, etc., if you you have multiple sizes.)
Next, make sure that you're managing config changes yourself in AndroidManifest.xml
:
Then put this in your main Activity class that extends DroidGap.java
:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (super.splashDialog != null) {
ViewGroup rootView = (ViewGroup) super.splashDialog.getWindow()
.getDecorView().findViewById(android.R.id.content);
LinearLayout linearLayout = (LinearLayout) rootView.getChildAt(0);
// manually refresh the splash image
linearLayout.setBackgroundDrawable(null);
linearLayout.setBackgroundResource(R.drawable.mysplash);
}
}
This will cause the background image to redraw and properly stretch whenever the user changes orientation.