Fast swipe handled by viewpager, not swipereveallayout
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>
I have the same problem
Same here
+1
Any solution on this?
In SwipeRevealLayout class, you can set this requestDisallowInterceptTouchEvent to true Mine problem was resolved getParent().requestDisallowInterceptTouchEvent(true);
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.