Search code examples
androidpanelandroid-videoviewsliding

Avoiding Sliding Panel collapsed on click with AndroidSlidingUpPanel


I'm using the AndroidSlidingUpPanel library. I've a VideoView in the SlidingPanel layout and I would like to interact with it (with the start \ stop controller) when the panel is expanded. But if I click on the panel, it will get collapsed again, so the video player is gone. How to solve this ?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FFFFFF"
    tools:context=".VideoMapPanel" >

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        xmlns:sothree="http://schemas.android.com/apk/res-auto"
        android:id="@+id/sliding_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom"
        sothree:panelHeight="68dp"
        sothree:shadowHeight="4dp"
        sothree:paralaxOffset="100dp"
        sothree:dragView="@+id/dragView">

        <!-- MAIN CONTENT -->
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            <android.support.v7.widget.Toolbar
                xmlns:sothree="http://schemas.android.com/apk/res-auto"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/main_toolbar"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                sothree:theme="@style/ActionBar"
                android:layout_width="match_parent"/>
            <TextView
                android:id="@+id/main"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="?attr/actionBarSize"
                android:gravity="center"
                android:text="Main Content"
                android:clickable="true"
                android:focusable="false"
                android:focusableInTouchMode="true"
                android:textSize="16sp" />



                <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />


        </FrameLayout>

        <!-- SLIDING LAYOUT -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#eeeeee"
            android:orientation="vertical"
            android:clickable="true"
            android:focusable="false"
            android:id="@+id/dragView">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="68dp"
                android:orientation="horizontal">

                <TextView
                    android:id="@+id/videoDescription"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
                    android:textSize="14sp"
                    android:textColor="@android:color/black"
                    android:textStyle="bold"
                    android:gravity="center_vertical"
                    android:paddingLeft="10dp"/>

                <Button
                    android:id="@+id/follow"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:textSize="14sp"
                    android:gravity="center_vertical|right"
                    android:paddingRight="10dp"
                    android:paddingLeft="10dp"/>

            </LinearLayout>


                                     <ProgressBar
            android:id="@+id/progressBar"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center|top"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:visibility="gone" >
        </ProgressBar>  


            <FrameLayout 
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="#FFFFFF"
   android:layout_gravity="center" >

     <VideoView

        android:id="@+id/liveView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>

  </FrameLayout>    

        </LinearLayout>
    </com.sothree.slidinguppanel.SlidingUpPanelLayout>

</RelativeLayout>

Solution

  • Solved, defining only the drag region to slide, in this way:

        layout = (SlidingUpPanelLayout)
                findViewById(R.id.sliding_layout); 
    
       layout.setDragView(findViewById(R.id.main_title_bar));
       layout.setEnableDragViewTouchEvents(true);