我說的最主要的是要在布局哪里設置一下,如:
<com.example.mypalyer.fullScreen
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
這里的com.example.mypalyer.fullScreen是我一個繼成了VideoView的一個類,具體如下:
public class fullScreen extends VideoView{
public fullScreen(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public fullScreen(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public fullScreen(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {//這里重寫onMeasure的方法
// TODO Auto-generated method stub
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = getDefaultSize(0, widthMeasureSpec);//得到默認的大小(0,寬度測量規范)
int height = getDefaultSize(0, heightMeasureSpec);//得到默認的大小(0,高度度測量規范)
setMeasuredDimension(width, height); //設置測量尺寸,將高和寬放進去
}
}
然后就沒有然后拉,直接用已經設置過的VideoView控件就可以了。