开发者

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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜