A SnapHelper that snaps a RecyclerView to an edge.
Java
4,979
165 commits
updated Mar 1, 2026
A SnapHelper that snaps a RecyclerView to an edge.
implementation("com.github.rubensousa:gravitysnaphelper:2.3.0")
You can either create a GravitySnapHelper, or use GravitySnapRecyclerView.
If you want to use GravitySnapHelper directly, you just need to create it and attach it to your RecyclerView:
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)
If you want to use GravitySnapRecyclerView, you can use the following xml attributes for customisation:
<attr name="snapGravity" format="enum">
<attr name="snapEnabled" format="boolean" />
<attr name="snapLastItem" format="boolean" />
<attr name="snapToPadding" format="boolean" />
<attr name="snapScrollMsPerInch" format="float" />
<attr name="snapMaxFlingSizeFraction" format="float" />
Example:
<com.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:snapGravity="start" />
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)

val snapHelper = GravitySnapHelper(Gravity.CENTER)
snapHelper.attachToRecyclerView(recyclerView)

If you use setMaxFlingSizeFraction or setMaxFlingDistance you can change the maximum fling distance allowed.


Take a look at these blog posts if you're using nested RecyclerViews
Copyright 2018 The Android Open Source Project
Copyright 2019 Rúben Sousa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
394 followers · starred Jan 2017
2,210 followers · starred Sep 2016
113 followers · starred Sep 2016
270 followers · starred Sep 2016
A SnapHelper that snaps a RecyclerView to an edge.
Java
4,979
165 commits
updated Mar 1, 2026
A SnapHelper that snaps a RecyclerView to an edge.
implementation("com.github.rubensousa:gravitysnaphelper:2.3.0")
You can either create a GravitySnapHelper, or use GravitySnapRecyclerView.
If you want to use GravitySnapHelper directly, you just need to create it and attach it to your RecyclerView:
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)
If you want to use GravitySnapRecyclerView, you can use the following xml attributes for customisation:
<attr name="snapGravity" format="enum">
<attr name="snapEnabled" format="boolean" />
<attr name="snapLastItem" format="boolean" />
<attr name="snapToPadding" format="boolean" />
<attr name="snapScrollMsPerInch" format="float" />
<attr name="snapMaxFlingSizeFraction" format="float" />
Example:
<com.github.rubensousa.gravitysnaphelper.GravitySnapRecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:snapGravity="start" />
val snapHelper = GravitySnapHelper(Gravity.START)
snapHelper.attachToRecyclerView(recyclerView)

val snapHelper = GravitySnapHelper(Gravity.CENTER)
snapHelper.attachToRecyclerView(recyclerView)

If you use setMaxFlingSizeFraction or setMaxFlingDistance you can change the maximum fling distance allowed.


Take a look at these blog posts if you're using nested RecyclerViews
Copyright 2018 The Android Open Source Project
Copyright 2019 Rúben Sousa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
394 followers · starred Jan 2017
2,210 followers · starred Sep 2016
113 followers · starred Sep 2016
270 followers · starred Sep 2016