SwipeRevealLayout icon indicating copy to clipboard operation
SwipeRevealLayout copied to clipboard

Fast swipe handled by viewpager, not swipereveallayout

Open kfjtrifork opened this issue 9 years ago • 6 comments

Thanks for your good library!

I am doing doing a viewpager and one of the pages are populated with a list of SwipeRevealLayout items. My problem is that a fast swipe on the SwipeRevealLayout item triggers the viewpager instead. Is there a way to ensure that it is the SwipeRevealLayout item, that is triggered, also for fast swipe?

layout_main.xml

<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"
    tools:context=".MainActivity">
<android.support.v4.view.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</RelativeLayout>

context.xml (RevealLayoutItem)

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_gravity="left"
    android:gravity="left"
    android:layout_margin="10dp"
    android:background="@android:color/black"
    android:layout_height="wrap_content"
    android:layout_width="match_parent">

    <com.chauthai.swipereveallayout.SwipeRevealLayout
        android:id="@+id/swipe_layout"
        android:layout_width="match_parent"
        android:layout_height="82dp"
        app:dragEdge="right"
        app:mode="same_level">

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="150dp"

                android:background="#00FF00"
                android:orientation="vertical"
                android:showDividers="middle"
                android:layout_margin="40dp">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="8dp"
                    android:text="Details" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="150dp"
                android:layout_marginRight="100dp"
                android:background="#ffffff"
                android:orientation="vertical"
                android:showDividers="middle">

                <TextView
                    android:id="@+id/row1_col1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="8dp"
                    android:text="Obligationslån, 5%" />
            </LinearLayout>

        </com.chauthai.swipereveallayout.SwipeRevealLayout>
</LinearLayout>

kfjtrifork avatar Jan 18 '17 08:01 kfjtrifork

I have the same problem

erik7667 avatar Aug 14 '17 15:08 erik7667

Same here

khataha92 avatar Oct 28 '17 20:10 khataha92

+1

jatin-lakhani avatar Apr 25 '18 06:04 jatin-lakhani

Any solution on this?

jatin-lakhani avatar Apr 25 '18 06:04 jatin-lakhani

In SwipeRevealLayout class, you can set this requestDisallowInterceptTouchEvent to true Mine problem was resolved getParent().requestDisallowInterceptTouchEvent(true);

MhtSuthar avatar Sep 12 '18 09:09 MhtSuthar

The explanation from @MhtSuthar gave me a good direction to solve this. For me, I had to use requestDisallowInterceptTouchEvent inside setOnTouchListener of swipeRevealLayout. For example:

(Kotlin)

swipeRevealLayout.setOnTouchListener { view, _ ->    
    view.parent.requestDisallowInterceptTouchEvent(true)
    false
}

(JAVA)

swipeRevealLayout.setOnTouchListener(new OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        v.getParent().requestDisallowInterceptTouchEvent(true)
        return false;
    }
});

That solved my problem of changing page when swiping right.

romaomb avatar Oct 24 '18 21:10 romaomb