Android Scrollview having videoview is giving prob

2019-01-09 01:40发布

I have a VideoView that is inside a scrollView. When I scroll the scrollView, the VideoView does not scroll with it. It is like its position is fixed. Here is my layout:

<?xml version="1.0" encoding="utf-8" ?> 
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF">
  <LinearLayout android:id="@+id/BackBar" android:orientation="vertical" android:layout_width="fill_parent" android:paddingTop="2dp" android:layout_height="wrap_content" android:background="#D6DEAA">
  <Button android:id="@+id/BackButton" android:layout_gravity="left" android:text="@string/BackButtonText" android:layout_width="wrap_content" android:layout_height="wrap_content" /> 
  </LinearLayout>
  <ScrollView android:id="@+id/scroll1" android:layout_height="fill_parent" android:layout_width="fill_parent">
  <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFFFFF">
  <LinearLayout android:id="@+id/contentVideo" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:paddingLeft="30px" android:paddingTop="15px" android:background="#FFFFFF">
  <TextView android:id="@+id/learn_hiv_blck1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/learn_hiv_blck1" android:textColor="#000000" android:textStyle="italic" android:background="#FFFFFF" android:layout_gravity="left" /> 
  <TextView android:id="@+id/learn_hiv_blck2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="15px" android:text="@string/learn_hiv_blck2" android:textColor="#000000" android:background="#FFFFFF" android:layout_gravity="left" /> 
  <TextView android:id="@+id/learn_hiv_blck3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="15px" android:text="@string/learn_hiv_blck3" android:textColor="#000000" android:background="#FFFFFF" android:layout_gravity="left" /> 
  <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#FFFFFF">
  <VideoView android:id="@+id/VideoView" android:layout_width="283dip" android:layout_height="183dip" /> 
  </LinearLayout>
  </LinearLayout>
  <LinearLayout android:id="@+id/contentVideo" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingLeft="30px" android:paddingTop="15px" android:paddingBottom="40dip" android:background="#FFFFFF">
  <TextView android:id="@+id/learn_hiv_blck4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/learn_hiv_blck4" android:textColor="#000000" android:background="#FFFFFF" android:layout_gravity="left" /> 
  <VideoView android:id="@+id/VideoView1" android:layout_width="280dip" android:layout_height="190dip" android:visibility="gone" /> 
  </LinearLayout>
  </LinearLayout>
  </ScrollView>
  </LinearLayout>

What is the problem in my layout?

4条回答
爷的心禁止访问
2楼-- · 2019-01-09 02:26

you cannot scroll videoview while playing as described here.

i had a videoview inside viewpage, when i scroll i pause the video and show image on top of it. "myby this work around can help"

查看更多
对你真心纯属浪费
3楼-- · 2019-01-09 02:36

You could also set for your VideoView:

    android:background:"#0000"
查看更多
祖国的老花朵
4楼-- · 2019-01-09 02:39

Romain Guy responded to this Android bug report:

This is a known limitation of VideoView. You should instead use TextureView in Android 4.0 and up.

查看更多
ら.Afraid
5楼-- · 2019-01-09 02:40

Call requestLayout() for the video view. It resolved same issue for me.

查看更多
登录 后发表回答