A simple, fast and beautiful widget for scrolling RecyclerView
Table of Contents
Download the latest AAR from jitpack via Gradle:
-
Gradle
Project build.gradle
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
app module build.gradle
dependencies { implementation 'com.github.mahdidev78:scrolltotop:TAG' }
-
Maven
Add the JitPack repository to your build file
<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
Add the dependency
<dependency> <groupId>com.github.mahdidev78</groupId> <artifactId>scrolltotop</artifactId> <version>Tag</version> </dependency>
Add the ScrollToTop to your layout :
<com.mahdikh.vision.scrolltotop.widget.ScrollToTop
android:id="@+id/scrollToTop"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_margin="10dp"
app:heavyCheckup="true"
app:minimumPosition="NO_POSITION"
app:minimumScroll="250dp"
app:rippleColor="#999999"
app:shortScroll="true"
app:smoothScroll="true" />
Setup your code :
-
Kotlin
val scrollToTop:ScrollToTop = findViewById(R.id.scrollToTop) scrollToTop.setupWithRecyclerView(recyclerView)
-
Java
ScrollToTop scrollToTop = findViewById(R.id.scrollToTop); scrollToTop.setupWithRecyclerView(recyclerView);
-
kotlin
scrollToTop.animator = ScaleAnimator().apply { duration = 250 fromScale = 0.8F maxAlpha = 0.8F interpolator = FastOutSlowInInterpolator() }
-
Java
ScaleAnimator animator = new ScaleAnimator(); animator.setDuration(250); animator.setFromScale(0.8F); animator.setMaxAlpha(0.8F); animator.setInterpolator(new FastOutSlowInInterpolator()); scrollToTop.setAnimator(animator);
FadeAnimator
, ScaleAnimator
, SlideAnimator
, FlyAnimator
attribute | Description | Options(examples) |
---|---|---|
smoothScroll | The default value is false | true/false |
shortScroll | The default value is false. If shortScroll is true, smoothScroll must also be true. | true/false |
heavyCheckup | If true, reacts when scrolling list, otherwise react when scrollState changes. | true/false |
rippleColor | oval ripple color. | #999999 |
minimumScroll | If the scroll value exceeds this value, ScrollToTop is displayed, otherwise it will be hidden. If the minimumPosition value is anything other than NOPOSITION, this value is ineffective. | 250dp |
minimumPosition | If the minimumPosition value is anything other than NOPOSITION, it means that if this position is scrolled and hidden, scrollToTop will appear. | 0, 2, 10 and etc |
- Android KitKat 4.4+
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Copyright 2021, mahdidev78
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.
Mahdi Khosravi - mahdi.khosravi.dev78@gmail.com
Project Link: https://github.com/mahdidev78/scrolltotop