13

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. How can I scroll the VideoView correctly with the scrolling of all other elements in the scrollView?

George
  • 3,727
  • 9
  • 31
  • 47
  • 1
    I also facing the same prob. Anyone have the solution? – dev_android May 05 '11 at 11:01
  • This seems to be a common problem. I'm looking for a solution too. Here is another question just in case one of these gets answered: http://stackoverflow.com/questions/5896921/android-scrollview-having-videoview-is-giving-problem – Tim Mahoney May 24 '11 at 16:59
  • 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: http://stackoverflow.com/questions/1096618/android-surfaceview-scrolling – Jon O Jun 22 '11 at 03:39

3 Answers3

12

The display is usually divided into two pipelines

  • Frame buffer pipeline - This is is where all your graphics is displayed. All the UI display elements go into this pipline
  • Video buffer pipeline - This is where your video data is diverted to.

Now when you declare a surface view you take up some screen space in the UI saying this is where the video will be displayed. So all other UI elements will not be able to occupy that space.

When scrolling happens your surface view will indeed be moved up or down depending on the scroll event but the problem is the video buffer pipeline does not care what happens in the frame buffer pipeline it goes on filling up the video data into the space in which it was initialised with.

So as of now you cannot scroll the video in android..

bluefalcon
  • 4,225
  • 1
  • 32
  • 41
7

Romain Guy said in this Android issue:

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

Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
0

You can put the videoview inside of a layout with an empty View over it.

    <RelativeLayout
        android:id="@+id/lay_live_video"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:visibility="visible" >

        <VideoView
            android:id="@+id/videoview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" />

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/transparent" />
    </RelativeLayout>

This code can be inside of your scrollview.

Sorry for my English, I'm learning ;)