diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java index 9eadaefb9e..c54fb0c8e6 100644 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxVideoView.java @@ -27,6 +27,7 @@ import android.media.MediaPlayer; import android.media.MediaPlayer.OnErrorListener; import android.net.Uri; import android.util.Log; +import android.view.Gravity; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; @@ -360,6 +361,7 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl FrameLayout.LayoutParams.WRAP_CONTENT); lParams.leftMargin = mVisibleLeft; lParams.topMargin = mVisibleTop; + lParams.gravity = Gravity.TOP | Gravity.LEFT; setLayoutParams(lParams); } diff --git a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java index 15a55841b7..c58ad937e8 100755 --- a/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java +++ b/cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxWebView.java @@ -6,6 +6,7 @@ import java.net.URI; import android.annotation.SuppressLint; import android.content.Context; import android.util.Log; +import android.view.Gravity; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -77,18 +78,15 @@ public class Cocos2dxWebView extends WebView { Cocos2dxWebViewHelper._didFailLoading(viewTag, failingUrl); } } - + public void setWebViewRect(int left, int top, int maxWidth, int maxHeight) { - fixSize(left, top, maxWidth, maxHeight); - } - - private void fixSize(int left, int top, int width, int height) { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.leftMargin = left; layoutParams.topMargin = top; - layoutParams.width = width; - layoutParams.height = height; + layoutParams.width = maxWidth; + layoutParams.height = maxHeight; + layoutParams.gravity = Gravity.TOP | Gravity.LEFT; this.setLayoutParams(layoutParams); } }