Android modifies the width and height of the Videoview

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.