From 9fc574415b007798345f7f760896434ce07b2c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BAben=20Sousa?= Date: Tue, 27 Aug 2019 23:52:31 +0100 Subject: [PATCH] Update README.md --- README.md | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 194bf7e..c9789d8 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ RecyclerView snapping example with SnapHelper -## How to +## Start/Top/End/Bottom Snapping If you need snapping support to start, top, end or bottom, use GravitySnapHelper. @@ -18,14 +18,6 @@ implementation 'com.github.rubensousa:gravitysnaphelper:2.1.0' implementation 'com.github.rubensousa:gravitysnaphelper-compat:2.0' ``` -Otherwise, center snapping is done with LinearSnapHelper. - -### Snapping center: - -```java -new LinearSnapHelper().attachToRecyclerView(recyclerView); -``` - ### Snapping start with GravitySnapHelper: ```java @@ -43,9 +35,26 @@ topRecyclerView.setLayoutManager(new LinearLayoutManager(this)); new GravitySnapHelper(Gravity.TOP).attachToRecyclerView(topRecyclerView); ``` -### If you're using nested RecyclerViews, take a look at: +## Center snapping + +```java +new LinearSnapHelper().attachToRecyclerView(recyclerView); +``` + +## Page snapping + +```java +new PagerSnapHelper().attachToRecyclerView(recyclerView); +``` + +## Nested RecyclerViews + +Take a look at these blog posts if you're using nested RecyclerViews + +1. [Improving scrolling behavior of nested RecyclerViews](https://rubensousa.com/2019/08/16/nested_recyclerview_part1/) + +2. [Saving scroll state of nested RecyclerViews](https://rubensousa.com/2019/08/27/saving_scroll_state_of_nested_recyclerviews/) -https://github.com/rubensousa/RecyclerViewSnap/blob/master/gravitysnaphelper/src/main/java/com/github/rubensousa/gravitysnaphelper/OrientationAwareRecyclerView.java ## License