2017-03-15 108 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"> 
相關問題