AndroidSwipeLayout icon indicating copy to clipboard operation
AndroidSwipeLayout copied to clipboard

ViewPager intercept swiping in items of recyclerview

Open Pei116 opened this issue 7 years ago • 3 comments

I have used SwipeLayout in the items of RecyclerView and the RecyclerView is in ViewPager. So hierarchy is just like ViewPager -> RecyclerView -> Item View -> SwipeLayout. When trying to swipe in SwipeLayout, it's sometimes triggered in ViewPager rather than in SwipeLayout. I have to carefully tap, hold and then swipe to make it working properly which would make users frustrated on it. Thanks in advance or any workaround if it's desired behavior.

Pei116 avatar Nov 01 '17 03:11 Pei116

Any luck with that. i'm also facing same issue ?

bliveinhack avatar Apr 28 '18 07:04 bliveinhack

Same here...

Stuazt avatar Jun 27 '19 03:06 Stuazt

Create custom view with extend of ViewPager

class SwipeLayoutViewPager(context: Context, attrs: AttributeSet) : ViewPager(context, attrs) {
    override fun canScroll(v: View, checkV: Boolean, dx: Int, x: Int, y: Int): Boolean {
        if (v is SwipeLayout) {
            return v.openStatus != SwipeLayout.Status.Close
        }
        return super.canScroll(v, checkV, dx, x, y)
    }
}

Use custom view pager in xml instead of support view pager

<com.example.example.SwipeLayoutViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

Profit :)

ZaydelEduard avatar Jan 09 '20 14:01 ZaydelEduard