今天遇到了个小问题,不知怎么回事,VideoView 虽然宽和高的属性都设为了match_parent,依然不能充满父级控件了。google 了一把找到了解决办法,自己也记录一下,以备不时之需。
原文链接:http://www.itstrike.cn/Question/03379f34-b5fb-44ce-9e5b-9072e9d7e633.html
http://stackoverflow.com/questions/16191262/stretch-to-fill-videoview-aspect-ratio-of-vidoeview
解决方法也很简单,看代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/trim_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
就是在你的VideoView控件放在一个RelativeLayout里面,然后设置VideoView宽和高为match_parent,然后在设置alignParent属性为true应该就可以了