开发者社区 问答 正文

请问Android播放不同分辨率视频怎么处理 ?

现在在做一个短视频的。从网络获取的视频可能是不同分辨率的。请问下大家该怎么处理显示大小

展开
收起
爵霸 2016-03-18 08:46:18 2924 分享 版权
1 条回答
写回答
取消 提交回答
  • 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) {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
            int width = getDefaultSize(0, widthMeasureSpec);
            int height = getDefaultSize(0, heightMeasureSpec);
            setMeasuredDimension(width, height);

    这是全屏播放的。 宽高你可以自己设置比例。

    2019-07-17 19:05:46
    赞同 展开评论