2017-03-15 110 views
0

此视频视图不会展开并将视频放入视图中。如果我设置静态高度和宽度(例如640dp 400dp),则视频会成功填充视图并按预期工作。当在ScrollView中填充时,Android VideoView不会扩展

这个问题出现在我进入ScrollView安装程序后 - 它在它自己的父LinearLayout中工作正常。

XML VideoView的:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/gray"> 


    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" > 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/top_video" 
      android:layout_alignParentTop="true" 
      android:orientation="vertical" 
      android:visibility="gone"> 

      <VideoView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:visibility="invisible" 
       android:layout_centerInParent="true" 
       android:id="@+id/video_view" /> 

     </RelativeLayout> 

     <!---- many more layouts and views that all get hidden when setting above to visible --> 
     <!---- many more layouts and views that all get hidden when setting above to visible --> 

    </LinearLayout> 
</ScrollView> 

回答

0

添加android:fillViewPort=true到您的滚动视图和匹配父高度

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:fillViewPort=true 
    android:layout_height="match_parent" 
    android:background="@color/gray"> 
相关问题