daimajia / AndroidSwipeLayout

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

swipe is notworking inside viewpager #532

Open hoangtuan051 opened 5 years ago

hoangtuan051 commented 5 years ago

when viewpager contains recyclerview inside fragment, it is only viewpager active and swipelayout not woking

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