【问题标题】:Zooming VideoView to fill the width, keeping aspect ratio缩放 VideoView 以填充宽度,保持纵横比
【发布时间】:2014-04-11 04:09:22
【问题描述】:

在我的活动中,我需要显示VideoView 实例(全屏),并带有一个缩放内容的按钮 - 类似于 iOS 媒体播放器的按钮。我的意思是例如缩放 4:3 内容以填充屏幕宽度,保持纵横比(从而有效修剪内容的顶部/底部)。

我刚刚做了一个快速的 hack/实验 - VideoViewAbsoluteLayout 内,超大,所以顶部/底部被修剪掉了。它可以工作,但感觉就像是 hack。

也许我是盲人,但没有 API 可以用于例如选择要在视图中显示的视频子矩形?

【问题讨论】:

    标签: android android-videoview


    【解决方案1】:

    您可以使用此代码使视频使用所有宽度:

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="center_horizontal">
    
        <VideoView
            android:id="@+id/myvideoid"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >
        </VideoView>
    </LinearLayout>
    

    在高度中使用匹配父项将使您的视频保持纵横比。 如果您想要填满屏幕,请访问http://blog.kasenlam.com/2012/02/android-how-to-stretch-video-to-fill.html

    【讨论】:

      猜你喜欢
      • 2013-08-07
      • 1970-01-01
      • 2013-04-17
      • 2017-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-01
      • 2015-11-03
      相关资源
      最近更新 更多