Jay S.
Jay S.

Reputation: 491

Interaction with a ViewPager in a SlidingUpPanel

I'm trying to use the SlidingUpPanel from umano and have the slider be a ViewPager.

However, when trying to scroll left and right the ViewPager isn't moving. It appears the touch events are being intercepted by the SlidingUpPanel.

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

    <com.sothree.slidinguppanel.SlidingUpPanelLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/slider_layout"
        android:layout_gravity="bottom">

        <!-- Top Panel -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
        </LinearLayout>

        <!-- Sliding Panel -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <android.support.v4.view.ViewPager
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/pager">
            </android.support.v4.view.ViewPager>

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

</RelativeLayout>

Upvotes: 1

Views: 1391

Answers (1)

user1923305
user1923305

Reputation: 51

Try:

  • Use the setDragView method for the ViewPager.
  • Use the setEnableDragViewTouchEvents so the dragview/ViewPager can have it's own touch events.

Alternatively make a seperate View apart from the ViewPager that is intended to be for dragging and set the DragView to this View accordingly, the ViewPAger should receive the touch events seperately and can handle them. (the latter is how I do it and works with other layout)

Upvotes: 5

Related Questions