Android 仿抖音全屏 VideoView

前言

效果如图

Android 仿抖音全屏 VideoView_第1张图片

项目需求,仿抖音全屏播放,直接上代码

FullScreenVideoView 工具类

public class FullScreenVideoView extends VideoView {
    public FullScreenVideoView(Context context) {
        super(context);
    }

    public FullScreenVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public FullScreenVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int width = getDefaultSize(0, widthMeasureSpec);
        int height = getDefaultSize(0, heightMeasureSpec);
        setMeasuredDimension(width, height);
    }
}

 使用

   

以上~

记录于 2018/11/15 14:58

你可能感兴趣的:(Android)