daimajia / AndroidSwipeLayout

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

Swipe not working inside a viewpager #482

Open abhishekBansal opened 6 years ago

abhishekBansal commented 6 years ago

I have two fragments inside a view pager. Last fragment has a recycler view where I am trying to implement Swipe to Dismiss with SwipeLayout. However, SwipeLayout isn't working when that fragment is in viewpager and works when that fragment is not inside a view pager. By not working i mean that swipewont reveal background and event is consumed by ViewPager itself.

arpitbandil commented 6 years ago

Hey, I am also using swipe reveal layout in viewpager fragment recycler view and it's working properly. Try some googling..

abhishekBansal commented 6 years ago

I tried, do you have swipe enabled in your view pager?

arpitbandil commented 6 years ago

Yes i had swipe enabled in view pager but the viewpager's fragment had nested scroll view due to my need and in nested scroll view i used recycler view and as a item of that recycler view i am using swipe reveal layout.

And its working perfectly! 👍 😃

bliveinhack commented 6 years ago

i had this same issue. if last viewpager has recycleView then it doesn't support Swiping .

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