daimajia / AndroidSwipeLayout

The Most Powerful Swipe Layout!
MIT License
12.37k stars 2.67k forks source link

ViewPager intercept swiping in items of recyclerview #478

Open Pei116 opened 6 years ago

Pei116 commented 6 years ago

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.

bliveinhack commented 6 years ago

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

Stuazt commented 5 years ago

Same here...

ZaydelEduard commented 4 years ago

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