VideoView--简单的设置全屏幕播放

本文介绍了一种通过自定义VideoView实现全屏播放的方法。主要步骤包括创建继承自VideoView的全屏播放类,并重写onMeasure方法来调整视图尺寸,确保视频能够全屏显示。

我说的最主要的是要在布局哪里设置一下,如:

 

 

     <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控件就可以了。

转载于:https://www.cnblogs.com/laijinquan/p/5947832.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值