rubensousa/GravitySnapHelper

Java
Android

A SnapHelper that snaps a RecyclerView to an edge.

recyclerviewsnappingandroid
Star 增长趋势
Star
5k
Forks
615
周增长
+0
Issues
0
2k4k
2016年8月2019年12月2023年4月2026年9月
制品库Maven
README

GravitySnapHelper

A SnapHelper that snaps a RecyclerView to an edge.

Setup

implementation("com.github.rubensousa:gravitysnaphelper:2.3.0")

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.
相关仓库
CymChad/BaseRecyclerViewAdapterHelper

BRVAH:Powerful and flexible RecyclerAdapter

KotlinlibraryMIT Licenserecyclerviewrecyclerview-adapter
recyclerview.org
24.6k5.2k
wasabeef/recyclerview-animators

An Android Animation library which easily add itemanimator to RecyclerView items.

KotlinlibraryApache License 2.0androidandroid-library
11.5k2k
cymcsg/UltimateRecyclerView

A RecyclerView(advanced and flexible version of ListView in Android) with refreshing,loading more,animation and many other features.

JavaMavenlibraryApache License 2.0javarecyclerview
7.2k1.4k
getActivity/AndroidProject

Android 技术中台,但愿人长久,搬砖不再有

JavaMavenlibraryApache License 2.0androidmvp
6.9k1.4k
yarolegovich/DiscreteScrollView

A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.

JavaMavenlibraryandroidview
5.8k779
drakeet/MultiType

Flexible multiple types for Android RecyclerView.

KotlinlibraryApache License 2.0android-libraryrecyclerview
5.8k748
yanzhenjie/SwipeRecyclerView

:melon: RecyclerView侧滑菜单,Item拖拽,滑动删除Item,自动加载更多,HeaderView,FooterView,Item分组黏贴。

JavaMavenlibraryApache License 2.0swipe-menuswipe-delete
github.com/yanzhenjie/SwipeRecyclerView
5.7k1.1k
TommyLemon/Android-ZBLibrary

🔥 Android MVP 快速开发框架,做国内 「示例最全面」「注释最详细」「使用最简单」「代码最严谨」的 Android 开源 UI 框架。 🔥 An Android MVP Framework with many demos, detailed documents, simple usages and strict codes.

JavaMavenlibraryApache License 2.0zxingokhttp
5.6k1.4k
Flipkart/recyclerlistview

High performance listview for React Native and web!

TypeScriptnpmApache License 2.0react-nativerecyclerview
5.4k439
h6ah4i/android-advancedrecyclerview

RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

JavaMavenlibraryApache License 2.0androidrecyclerview
advancedrecyclerview.h6ah4i.com
5.3k847
XRecyclerView/XRecyclerView

A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

JavaMavenlibraryrecyclerviewfeatrue
5.3k1.2k
vipulasri/Timeline-View

Timeline View is a simple and highly customizable android library for creating shipment/order tracking, step progress indicators, etc.

JavaMavenlibraryApache License 2.0androidtimeline
vipulasri.github.io/Timeline-View/
3.9k640