• Stars
    star
    101
  • Rank 336,429 (Top 7 %)
  • Language
    Java
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

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