Android::VideoView inside a ScrollView

前端 未结 3 1468
我寻月下人不归
我寻月下人不归 2020-12-09 05:02

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 V

相关标签:
3条回答
  • 2020-12-09 05:40

    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 ;)

    0 讨论(0)
  • 2020-12-09 05:46

    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..

    0 讨论(0)
  • 2020-12-09 05:51

    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.

    0 讨论(0)
提交回复
热议问题