VideoView重绘

知识点:Android中的VideoView控件默认情况下是不能全屏播放的,它是固有的比例播放,假如你放在默认播放会有黑框
解决的办法是重写VideoView控件

实现代码如下:

package com.shenghe.bank.landi.helper;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.VideoView;

public class MvideoView extends VideoView {
	
	public MvideoView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	private int mwidth=0;
	private int mheight=0;

	 @Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		 int width=getDefaultSize(mwidth, widthMeasureSpec);
		 int height=getDefaultSize(mheight, heightMeasureSpec);
		 setMeasuredDimension(width, height);
	}

}


注意:必须实现这个构造public MvideoView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

你可能感兴趣的:(android)