Video doesn't fit properly
Hi I have a VideoView in my app, provided the layout width and height as fill parent. But still my video is displayed only in half the portion of the videoView. So I tried providing the width and height in dip. But still the video displays in the same manner. Can anyone help me with t开发者_Python百科his?
I had the same problem. I solved it by creating an own VideoView class extending VideoView, then pass in the width and height from
new VideoPlayer(this, getWindowManager().getDefaultDisplay().getWidth(), getWindowManager().getDefaultDisplay().getHeight());
And this is the VideoPlayer class
public class VideoPlayer extends VideoView {
private int width;
private int height;
public VideoPlayer(Context context, int width, int height) {
super(context);
this.width = width;
this.height = height;
}
public VideoPlayer(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
{
setMeasuredDimension(width, height);
}
}
I then added the VideoPlayer view by code to the layout using ViewGroup.addView(VideoPlayer)
精彩评论