Updated Branches:
  refs/heads/master 1782111d4 -> ba3142460

Keep the splashscreen image ratio instead of streatching it.
An ImageView is used to be able to use ScaleType.CENTER_CROP, which is similar 
to the background-size:cover CSS property


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/ba314246
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/ba314246
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/ba314246

Branch: refs/heads/master
Commit: ba314246047501c36916604facb5e097572771e4
Parents: 1782111
Author: Steren <[email protected]>
Authored: Tue Apr 2 02:02:45 2013 +0200
Committer: Andrew Grieve <[email protected]>
Committed: Thu Apr 4 16:19:12 2013 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/DroidGap.java |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/ba314246/framework/src/org/apache/cordova/DroidGap.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/DroidGap.java 
b/framework/src/org/apache/cordova/DroidGap.java
index d4296cb..a9efc93 100755
--- a/framework/src/org/apache/cordova/DroidGap.java
+++ b/framework/src/org/apache/cordova/DroidGap.java
@@ -51,6 +51,7 @@ import android.view.View;
 import android.view.ViewGroup;
 import android.view.Window;
 import android.view.WindowManager;
+import android.widget.ImageView;
 import android.webkit.ValueCallback;
 import android.webkit.WebViewClient;
 import android.widget.LinearLayout;
@@ -1031,7 +1032,13 @@ public class DroidGap extends Activity implements 
CordovaInterface {
                 
root.setBackgroundColor(that.getIntegerProperty("backgroundColor", 
Color.BLACK));
                 root.setLayoutParams(new 
LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                         ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
-                root.setBackgroundResource(that.splashscreen);
+                // We want the splashscreen to keep its ratio, 
+                // for this we need to use an ImageView and not simply the 
background of the LinearLayout
+                ImageView splashscreenView = new ImageView(that.getActivity());
+                splashscreenView.setImageResource(that.splashscreen);
+                
splashscreenView.setScaleType(ImageView.ScaleType.CENTER_CROP); // similar to 
the background-size:cover CSS property
+                splashscreenView.setLayoutParams(new 
LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 
ViewGroup.LayoutParams.FILL_PARENT));
+                root.addView(splashscreenView);
 
                 // Create and show the dialog
                 splashDialog = new Dialog(that, 
android.R.style.Theme_Translucent_NoTitleBar);

Reply via email to