A beautiful widget for displaying numbers with animation
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:numberview: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>numberview</artifactId> <version>Tag</version> </dependency>
Add the NumberView to your layout :
<com.mahdikh.vision.numberview.widget.NumberView
android:id="@+id/numberView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="45sp"
app:animator="@string/DefaultAnimator"
app:duration="300"
app:interpolator="@android:interpolator/accelerate_decelerate"
app:number="10" />
Setup your code :
-
Kotlin
val numberView:NumberView = findViewById(R.id.numberView) numberView.setOnClickListener { numberView.increment() }
-
Java
NumberView numberView = findViewById(R.id.numberView); numberView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { numberView.increment(); } });
-
kotlin
numberView.animator = SlideAnimator().apply { setDuration(450) setInterpolator(FastOutSlowInInterpolator()) gravity = Gravity.END }
-
Java
SlideAnimator animator = new SlideAnimator(Gravity.END); animator.setDuration(450); animator.setInterpolator(new FastOutSlowInInterpolator()); numberView.setAnimator(animator);
DefaultAnimator
, SlideAnimator
, FadeAnimator
, ScaleAnimator
, RotationAnimator
, FlipAnimator
attribute | Description | Options(examples) |
---|---|---|
number | The desired number to set as text | 20,486, ... |
animator | animator class name | FadeAnimator,ScaleAnimator, etc |
duration | animator duration | 500, 600, etc |
interpolator | animator interpolator | @android:interpolator/overshoot |
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
Distributed under the Apache2.0 License. See LICENSE
for more information.
Mahdi Khosravi - mahdi.khosravi.dev78@gmail.com
Project Link: https://github.com/mahdidev78/numberview