Fix WebView and VideoPlayer in wrong place on Android 2.3.x

This commit is contained in:
Dhilan007 2014-11-13 18:15:41 +08:00
parent 706f49cb59
commit 5a8ac8f151
2 changed files with 7 additions and 7 deletions

View File

@ -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);
}

View File

@ -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;
@ -79,16 +80,13 @@ public class Cocos2dxWebView extends WebView {
}
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);
}
}