Video In Webview Should Display Full Screen On Onshowcustomview() Method In Android
i want to display video full screen (that is full screen horizontally) landscape.. when onShowCustomView() method is called , what is happening in my case is that video is display
Solution 1:
I just faced your problem and I deal with it in another way.
Actually, the view returned by onShowCustomView is a VideoView or its father. It stands vertical because your device orientation is portrait. So we can do something on the fullscreen view's container. Just make a "landscape" layout as your container.
Here is my simple code:
publicclassLandscapeFrameLayoutextendsFrameLayout {
publicLandscapeFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
@OverrideprotectedvoidonMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.getSize(heightMeasureSpec));
}
@OverrideprotectedvoidonLayout(boolean changed, int left, int top, int right, int bottom) {
//Attention: The arithmetic below is based on padding == 0.finalintcount= getChildCount();
for (inti=0; i < count; i++) {
Viewchild= getChildAt(i);
if (child != null) {
child.setRotation(90);
intwidth= right - left;
intheight= bottom - top;
child.setTranslationX((width - height) / 2);
child.setTranslationY((height - width) / 2);
}
}
super.onLayout(changed, 0, 0, bottom, right);
}
}
What the code above do is rotate its children by 90 degree and adjust there position.
Post a Comment for "Video In Webview Should Display Full Screen On Onshowcustomview() Method In Android"