Skip to content

This is an extension of RecyclerView to add ViewPager-like snapping and scrolling, as well as a custom implementaion of swiping behaviour. The swiping is different from the default ItemTouchHelper that it supports only allowing swiping after long press.

Notifications You must be signed in to change notification settings

CarlLee/SnappingSwipingRecyclerView

Repository files navigation

Preview

Intro

SnappingSwipingRecyclerView is an implementation of "viewpager-like" behavior of RecyclerView, but it also adds a "long press to swipe" pattern like used in Wechat Reading, A.K.A, 微信读书, in Chinese.

Usage

You can use classes like SwipeGestureHelper, SnappyRecyclerView, SnappyLinearLayoutManager, MarginDecoration directly, just read their Java doc.

Or, you can simply use this convenient SnappingSwipingViewBuilder class to save you some work.

    RecyclerView recyclerView = new SnappingSwipingViewBuilder(this)
                    .setAdapter(mAdapter)
                    .setHeadTailExtraMarginDp(17F)
                    .setItemMarginDp(8F, 20F, 8F, 20F)
                    .setOnSwipeListener(this)
                    .setSnapMethod(SnappyLinearLayoutManager.SnappyLinearSmoothScroller.SNAP_CENTER)
                    .build();

TODOs

  • Add support for vertical layouts
  • Add relative width support for item views

About

This is an extension of RecyclerView to add ViewPager-like snapping and scrolling, as well as a custom implementaion of swiping behaviour. The swiping is different from the default ItemTouchHelper that it supports only allowing swiping after long press.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages