VideoView--簡單的設置全屏幕播放


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

 

 

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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM