Android Scrollview having videoview is giving problem

13,733

You could also set for your VideoView:

    android:background:"#0000"
Share:
13,733
dev_android
Author by

dev_android

Updated on June 17, 2022

Comments

  • dev_android
    dev_android almost 2 years

    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?

    • Tim Mahoney
      Tim Mahoney almost 13 years
      I have this same problem. The Surface is creating a hole in the screen where it wants to draw, but it isn't moving with the layout. I am currently trying to find a solution, and I am becoming increasingly afraid that I'll need to do this in native code. In case one of these gets answered, here is another question on the same topic: stackoverflow.com/questions/4312585/…
    • Jon O
      Jon O almost 13 years
      VideoView inherits from SurfaceView, which changes the rules of scrolling behavior. A SurfaceView is basically a layover on top of whatever else is going on, and it seems like you're on your own as far as updates are concerned. See also this question, if it helps at all: stackoverflow.com/questions/1096618/…
    • Ken White
      Ken White almost 13 years
      You are aware that copy/paste of answers to multiple questions is frowned upon here, right? (stackoverflow.com/questions/6434646)
  • Ivo Jansch
    Ivo Jansch about 12 years
    This workaround worked fine in a similar case; somehow it causes the screen to properly redraw.
  • Pencilcheck
    Pencilcheck over 10 years
    You mean android:background="#0000"?
  • Unknownweirdo
    Unknownweirdo almost 10 years
    This was great for when in a ViewPager too for older devices. Massive thank you!
  • Nidhi
    Nidhi over 9 years
    Perfect solution. Thanks a lot.. :)
  • okarakose
    okarakose almost 8 years
    not worked for me. ScrollView -> RelativeLayout -> VideoView