CarlLee / SnappingSwipingRecyclerView

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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.


Languages

Language:Java 100.0%