Android中的videoview控件在android中不能设置宽高,需要重写videoView中的onMeasure()方法,才可以设置videoview的宽和高。重写的videoview代码如下:

让VideoView可以手动的设置长宽

/** * The CustomVideoView is to make videoView view length-width based on the parameters you set to decide. * @author peter. * */public class CustomVideoView extends VideoView {private int mVideoWidth;    private int mVideoHeight;    public CustomVideoView(Context context) {        super(context);    }     public CustomVideoView(Context context, AttributeSet attrs) {        super(context, attrs);    }     public CustomVideoView(Context context, AttributeSet attrs, int defStyle) {        super(context, attrs, defStyle);    }     @Override    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {    /* The following code is to make videoView view length-width     based on the parameters you set to decide. */    int width = getDefaultSize(mVideoWidth, widthMeasureSpec);        int height = getDefaultSize(mVideoHeight, heightMeasureSpec);        setMeasuredDimension(width, height);    }}


更多相关文章

  1. Android 自动化测试—robotium(五)Spinner控件
  2. Android TextView内容居中和控件居中
  3. 系出名门Android(5) - 控件(View)之TextView, Button, ImageButt
  4. Android学习笔记35——ProgressBar进度控件详解
  5. 【Android 开发】:UI控件之 ListView 列表控件的使用
  6. Android 中的时间日期控件
  7. IKNinePhotoView 是一个开源的 Android 九宫格控件,可以自适应宽
  8. Android之——自定义复合控件的实现

随机推荐

  1. 总结Content Provider的使用
  2. 【Based Android】PreferenceActivity设
  3. android 抛出“Unparsed aapt error(s)”
  4. Android性能优化之 Android Lint
  5. Android中怎么让你的layout适应屏幕的大
  6. Android中Dialog
  7. Android平台架构介绍和源码下载
  8. Android网格布局(GirdView)学习
  9. android:ellipsize属性
  10. Android开发进阶之NIO非阻塞包(三)