mirror of https://github.com/axmolengine/axmol.git
Fix WebView and VideoPlayer in wrong place on Android 2.3.x
This commit is contained in:
parent
706f49cb59
commit
5a8ac8f151
|
@ -27,6 +27,7 @@ import android.media.MediaPlayer;
|
||||||
import android.media.MediaPlayer.OnErrorListener;
|
import android.media.MediaPlayer.OnErrorListener;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
|
@ -360,6 +361,7 @@ public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
lParams.leftMargin = mVisibleLeft;
|
lParams.leftMargin = mVisibleLeft;
|
||||||
lParams.topMargin = mVisibleTop;
|
lParams.topMargin = mVisibleTop;
|
||||||
|
lParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
setLayoutParams(lParams);
|
setLayoutParams(lParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.net.URI;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.webkit.WebChromeClient;
|
import android.webkit.WebChromeClient;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
@ -77,18 +78,15 @@ public class Cocos2dxWebView extends WebView {
|
||||||
Cocos2dxWebViewHelper._didFailLoading(viewTag, failingUrl);
|
Cocos2dxWebViewHelper._didFailLoading(viewTag, failingUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWebViewRect(int left, int top, int maxWidth, int maxHeight) {
|
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 layoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||||
FrameLayout.LayoutParams.WRAP_CONTENT);
|
FrameLayout.LayoutParams.WRAP_CONTENT);
|
||||||
layoutParams.leftMargin = left;
|
layoutParams.leftMargin = left;
|
||||||
layoutParams.topMargin = top;
|
layoutParams.topMargin = top;
|
||||||
layoutParams.width = width;
|
layoutParams.width = maxWidth;
|
||||||
layoutParams.height = height;
|
layoutParams.height = maxHeight;
|
||||||
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
this.setLayoutParams(layoutParams);
|
this.setLayoutParams(layoutParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue