If you are using Android Videoview directly. He is not allowed to modify the width and height arbitrarily, so we have to rewrite the videoview!
Package Com.hysmarthotel.view;
Import Android.content.Context;
Import Android.util.AttributeSet;
Import Android.widget.VideoView;
public class Myvideoview extends videoview{
Public Myvideoview (Context context) {
Super (context);
}
Public Myvideoview (context context, AttributeSet Attrs) {
Super (context, attrs);
}
Public Myvideoview (context context, AttributeSet attrs, int defstyle) {
Super (context, attrs, Defstyle);
}
@Override
protected void onmeasure (int widthmeasurespec, int heightmeasurespec) {
Super.onmeasure (Widthmeasurespec, Heightmeasurespec);
int width = getdefaultsize (getwidth (), widthmeasurespec);
int height = getdefaultsize (getheight (), heightmeasurespec);
Setmeasureddimension (width, height);
}
}
Mainly is the Onmeasure method, we rewrite the Onmeasure method without Google's, so that we can arbitrarily control the width and height of the Videoview
Android modifies the width and height of the Videoview