• Stars
    star
    4,987
  • Rank 8,375 (Top 0.2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created about 8 years ago
  • Updated almost 3 years ago

Reviews

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

Repository Details

A SnapHelper that snaps a RecyclerView to an edge.

GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.

Setup

Add this to your build.gradle:

implementation 'com.github.rubensousa:gravitysnaphelper:2.2.2'

How to use

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" />

Start snapping

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

Center snapping

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

Limiting fling distance

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

With decoration

Features

  1. setMaxFlingDistance or setMaxFlingSizeFraction - changes the max fling distance allowed.
  2. setScrollMsPerInch - changes the scroll speed.
  3. setGravity - changes the gravity of the SnapHelper.
  4. setSnapToPadding - enables snapping to padding (default is false)
  5. smoothScrollToPosition and scrollToPosition
  6. RTL support out of the box

Nested RecyclerViews

Take a look at these blog posts if you're using nested RecyclerViews

  1. Improving scrolling behavior of nested RecyclerViews

  2. Saving scroll state of nested RecyclerViews

License

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.

More Repositories

1

ViewPagerCards

ViewPager cards inspired by Duolingo
Java
4,065
star
2

PreviewSeekBar

A SeekBar suited for showing a preview of something. As seen in Google Play Movies.
Java
3,437
star
3

FloatingToolbar

A toolbar that morphs from a FloatingActionButton
Java
1,551
star
4

BottomSheetBuilder

A simple library that creates BottomSheets according to the Material Design specs
Java
558
star
5

Decorator

Decorator is an Android library that helps creating composable margins and dividers in RecyclerViews
Kotlin
533
star
6

RaiflatButton

A raised button that lowers down to 0dp of elevation
Java
330
star
7

RecyclerViewNestedExample

From: https://rubensousa.com/2019/08/16/nested_recyclerview_part1/ and https://rubensousa.com/2019/08/27/saving_scroll_state_of_nested_recyclerviews/
Kotlin
165
star
8

BottomSheetExample

A sample project with the new BottomSheet classes from the android support library
Java
129
star
9

Transitions

A sample that showcases some transitions
Java
118
star
10

DpadRecyclerView

A RecyclerView built for Android TV with Compose in mind and as a replacement for Leanback's BaseGridView.
Kotlin
103
star
11

SlidingTabs

Tabs created with the new android.support.design.widget.TabLayout
Java
25
star
12

StackView

A view that arranges its children in the form of a stack
Java
16
star
13

lista

Lista helps you building composable sections and nested lists in RecyclerViews.
Kotlin
14
star
14

LoadMoreAdapter

A RecyclerView adapter that offers support to loading more items
Java
9
star
15

AndroidGithubPackage

Sample Android library that's published to GitHub Packages using a GitHub Action
Java
5
star
16

FragmentContainerViewIssue

https://issuetracker.google.com/issues/146359827
Kotlin
3
star
17

TabLayoutAdapter

A helper library to easily create tabs with TabLayout
Java
3
star
18

NavigationViewExample

An example app with NavigationView of the android.support.design library
Java
3
star
19

CropView

A simple view that selects an area for cropping
Java
3
star
20

WorkManagerKitkatBug

https://issuetracker.google.com/issues/122578012
Kotlin
2
star
21

rubensousa.github.io

SCSS
2
star
22

Android_8.0_Accessibility_Crash

Kotlin
2
star
23

WorkManagerConcurrent

https://issuetracker.google.com/issues/121345393
Kotlin
1
star
24

Mieti

Aplicação para o cálculo da média do Mestrado Integrado em Engenharia de Telecomunicações e Informática da Universidade do Minho.
Java
1
star
25

adventofcode2017

Solutions for Advent of Code
Kotlin
1
star
26

StateSaverIssue

Java
1
star