daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ViewPager intercept swiping in items of recyclerview

Pei116 opened this issue · 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.

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

Same here...

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 :)