AndroidSwipeLayout icon indicating copy to clipboard operation
AndroidSwipeLayout copied to clipboard

Swipe not working inside a viewpager

Open abhishekBansal opened this issue 6 years ago • 5 comments

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.

abhishekBansal avatar Nov 29 '17 08:11 abhishekBansal

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

arpitbandil avatar Dec 11 '17 04:12 arpitbandil

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

abhishekBansal avatar Dec 11 '17 08:12 abhishekBansal

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! 👍 😃

arpitbandil avatar Dec 11 '17 11:12 arpitbandil

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

bliveinhack avatar Apr 28 '18 07:04 bliveinhack

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