求助videoView,视频源的尺寸无法布满VIEW如何修改,求大神指教

xcpxcp198608 2016-05-16 05:42:01
新人学习android的vitamio时,播放电视源时,好像是视频源的尺寸太小,无法布满videoview,显示在左边,求大神前辈指导如何改到拉伸到全屏或在view的中间显示
目前状态:
...全文
5294 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
it_弈风 2018-06-07
  • 打赏
  • 举报
回复
我刚也碰到这个问题,找到解决方法了,总的来说也是重写VideoVIew 的onMeasure,但是看到这个帖子写的比较详细,新手应该能直接看懂 下次再挖到这个帖子的网友可以看看。 https://blog.csdn.net/DickyQie/article/details/51957397?locationNum=1&fps=1
Yuke213 2018-04-01
  • 打赏
  • 举报
回复
设置VideoView的属性centerinparent="true",试一下。
whoami_han 2017-08-25
  • 打赏
  • 举报
回复
重写VideoVIew 的onMeasure,
public class MyVideoView extends VideoView {
    public MyVideoView(Context context) {
        super(context);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int widthSize = MeasureSpec.getSize(widthMeasureSpec);
        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
        int heightSize = MeasureSpec.getSize(heightMeasureSpec);
        int heightMode = MeasureSpec.getMode(heightMeasureSpec);
        if (widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY) {
            setMeasuredDimension(widthSize, heightSize);
        } else {
            super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        }
    }
}
乔瑟琳111 2017-08-24
  • 打赏
  • 举报
回复
在线急急急,求各路大神帮助啊
乔瑟琳111 2017-08-24
  • 打赏
  • 举报
回复
有其他解决方案吗?这些试了都不行啊
七叶林 2017-02-07
  • 打赏
  • 举报
回复
有两种方法,仅供参考,共同学习,欢迎指正 1、通过LayoutParams即可设置视频源全屏 @Override public void onConfigurationChanged(Configuration newConfig) { if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { Log.d("haha","切换横屏"); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); videoView.setLayoutParams(layoutParams); } super.onConfigurationChanged(newConfig); } 2、重写onMeasure,布局设置 match_parent @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSize = MeasureSpec.getSize(widthMeasureSpec); int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); if(widthMode == MeasureSpec.EXACTLY && heightMode == MeasureSpec.EXACTLY) { setMeasuredDimension(widthSize,heightSize); } else { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } }
qq_22254477 2016-11-25
  • 打赏
  • 举报
回复
重新计算吧。。。。。。。。。。。。。。
lwlizhe 2016-08-04
  • 打赏
  • 举报
回复
setLayoutParams貌似有用……
youlongno1 2016-08-04
  • 打赏
  • 举报
回复
楼主,问题解决了吗?我也遇到这样的问题了
七绝x 2016-07-26
  • 打赏
  • 举报
回复
外层套相对布局,设置 android:layout_centerInParent="true" 属性,我前不久刚做个这个 <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" > <VideoView android:id="@+id/video_view" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_centerInParent="true" /> </RelativeLayout>
bravefyg 2016-07-26
  • 打赏
  • 举报
回复
自定义一下view public class CustomVideoView extends VideoView { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { //我们重新计算高度 int width = getDefaultSize(0, widthMeasureSpec); int height = getDefaultSize(0, heightMeasureSpec); setMeasuredDimension(width, height); }
air青 2016-07-18
  • 打赏
  • 举报
回复
我在使用vitamio的时候希望他填充到一个区域中,不是全屏的,好像怎么设置都不行,有办法设置吗
xcpxcp198608 2016-05-20
  • 打赏
  • 举报
回复
引用 4楼我是你的主体 的回复:
[quote=引用 2楼诸葛非常的亮 的回复:]<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="vertical" > <VideoView android:id="@+id/videoView1" android:layout_width="match_parent" android:layout_height="match_parent" /> 注意红色 </LinearLayout>
View 是全屏的,问题是视频源尺寸占不满view[/quote]我换个视频源就可以占满
xcpxcp198608 2016-05-20
  • 打赏
  • 举报
回复
引用 2楼诸葛非常的亮 的回复:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="vertical" > <VideoView android:id="@+id/videoView1" android:layout_width="match_parent" android:layout_height="match_parent" /> 注意红色 </LinearLayout>
View 是全屏的,问题是视频源尺寸占不满view
qq_35039117 2016-05-18
  • 打赏
  • 举报
回复
布局居中,然后占满全局 match_parent
诸葛非常的亮 2016-05-18
  • 打赏
  • 举报
回复
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:orientation="vertical" > <VideoView android:id="@+id/videoView1" android:layout_width="match_parent" android:layout_height="match_parent" /> 注意红色 </LinearLayout>
伊卡丘 2016-05-16
  • 打赏
  • 举报
回复
对surface 修改viewport

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧