Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensousa authored Aug 27, 2019
1 parent b723213 commit 9fc5744
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RecyclerView snapping example with SnapHelper

<img src="screens/snap_googleplay.gif" width=300></img> <img src="screens/snap_final.gif" width=300></img>

## How to
## Start/Top/End/Bottom Snapping

If you need snapping support to start, top, end or bottom, use GravitySnapHelper.

Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 9fc5744

Please sign in to comment.