🚀 A library that helps you animate change in numeric values in a TextView

Overview

AnimatedCountTextView

A library that helps you animate change in numeric values in a TextView.

Build Status Download

Gradle Dependency

Add the dependency to your app's build.gradle:

implementation 'com.r4sh33d:AnimatedCountTextView:0.0.1'

Usage

Add the AnimatedCountTextView to your layout.

<com.r4sh33d.animatedcounttextview.AnimatedCountTextView
    app:startWith="0"
    app:endWith="100"
    app:duration="4000"
    app:suffix="%"
    app:numberType="integer"
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    android:textSize="30sp" />

Then call the start() method to start the count:

countTextView.start()

You can optionally listen for the count end event by setting a CountEndListener

countTextView.countEndListener(object : CountEndListener {
      override fun onCountFinish() {
           // Do something 
      }
   })

If required, you can also stop the count at any time by calling the stop() method:

countTextView.stop()

That's all for basic usage. Your AnimatedCountTextView should animate form your startWith value to endWith value within the given time duration.

Customisation

AnimatedCountTextView attempts to use some default values to simplify the usage. The behaviour can be further customized by setting the following attributes via xml or code.

Start and End values

You can use the xml attributes startWith and the endWith values to specify the value to animate from, and value to animate to, respectively.

<com.r4sh33d.animatedcounttextview.AnimatedCountTextView
    ...
    app:startWith="0"
    app:endWith="100"/>

or programmatically:

countTextView.startWith(0)
countTextView.endWith(100)

Duration

You can specify the duration(in milliseconds) for the count-up or count-down animation using the duration attribute in xml.

<com.r4sh33d.animatedcounttextview.AnimatedCountTextView
    ...
    app:duration="4000"/>

or programmatically:

countTextView.duration(4000)

Number Type

You can use NumberType to specify the type of number you want to animate. You can either specify NumberType.Integer() or NumberType.Decimal(). You can also apply custom formatting to display the animated values. Custom formats can be specified by passing a DecimalFormat to NumberType.Integer() or NumberType.Decimal() constructor. The default NumberType is Integer.

<com.r4sh33d.animatedcounttextview.AnimatedCountTextView
    ...
    app:numberType="integer"/>

Programmatically:

countTextView.numberType(NumberType.Decimal(twoDecimalPlacesFormat))
//or 
countTextView.numberType(NumberType.Integer())

Prefix and Suffix

You can specify prefix and/or suffix to the animated values. This is useful if you want to specify a currency symbol as a prefix or the percentage sign as the suffix.

<com.r4sh33d.animatedcounttextview.AnimatedCountTextView
    ...
    app:suffix="%"
    app:prefix="$"/>

or programmatically:

countTextView.prefix("$")
//or 
countTextView.suffix("%")

Interpolator

You can specify the Interpolator to use when animating the values. This can only be done programmatically:

countTextView.interpolator(AccelerateDecelerateInterpolator())

License

Copyright (c) 2019 Rasheed Sulayman.

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.
You might also like...
ArcAnimator helps to create arc transition animation: 2.3.+
ArcAnimator helps to create arc transition animation: 2.3.+

ArcAnimator ArcAnimator helps to create arc transition animation: 14+ | ArcAnimator Demo | TransitionLoop Demo* *TransitionLoop Prototype by Min-Sang

A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates
A Simple Todo app design in Flutter to keep track of your task on daily basis. Its build on BLoC Pattern. You can add a project, labels, and due-date to your task also you can sort your task on the basis of project, label, and dates

WhatTodo Life can feel overwhelming. But it doesn’t have to. A Simple To-do app design in flutter to keep track of your task on daily basis. You can a

You don’t want your apps look and feel boring, do you? Add some bubbles!
You don’t want your apps look and feel boring, do you? Add some bubbles!

#BubbleAnimationLayout Say hello to Bubble Animation Layout for Android by Cleveroad You don’t want your apps look and feel boring, do you? Add some b

Road Runner is a library for android which allow you to make your own loading animation using a SVG image
Road Runner is a library for android which allow you to make your own loading animation using a SVG image

Road Runner Road Runner is a library for android which allow you to make your own loading animation using a SVG image Sample video View in Youtube Dem

Android library which allows you to swipe down from an activity to close it.
Android library which allows you to swipe down from an activity to close it.

Android Sliding Activity Library Easily create activities that can slide vertically on the screen and fit well into the Material Design age. Features

A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix.
A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix.

SuperForwardView About A lightweight android library that allows to you create custom fast forward/rewind animations like on Netflix. GIF Design Credi

🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

Orbitary 🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition. Download Gradle Add the depen

🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.
🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

🪐 Jetpack Compose animation library that allows you to implement animations such as shared element transition.

You can easily access the top of the screen in Android. Like a iPhone 6 & 6 Plus.
You can easily access the top of the screen in Android. Like a iPhone 6 & 6 Plus.

Reachability on Android Easy access on top. Like a iPhone 6 & 6 Plus. demo apk Usage Add dependencies compile 'com.github.sakebook:Reachability:0.2.0@

Owner
Rasheed Sulayman
Mobile Engineer
Rasheed Sulayman
POC of how you can animate LazyColumn insertions/deletions/moving

Animated LazyColumn/LazyRow POC of how you can animate LazyColumn/LazyRow insertions/deletions/moving Note, this is not production ready or a library,

Roudi Korkis Kanaan 33 Dec 24, 2022
Android library to animate Floating Action Button to Bottom Sheet Dialog and vice-versa

FabulousFilter Show some ❤️ and star the repo to support the project This library is the implementation of filter-concept posted on MaterialUp.com. It

Krupen Ghetiya 2.6k Jan 3, 2023
Simple way to animate your views on Android with Rx 🚀

This is an Android library to make a simple way to animate your views on Android with Rx.

Lopez Mikhael 583 Dec 9, 2022
Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines.

StrikedImageView Animate a strike over any image to indicate on/off states. As seen in the Material Guidelines. Gradle allprojects { repositories

null 9 Sep 21, 2022
Animated-splash-screen - Animate your Splash Screen using Lottie files.

Animated Splash Screen This small project shows how you can add animation into your android projects or create beautiful looking Splash Screen or Laun

Aashish Ace 0 Jan 2, 2022
Backarrow-animation-example - Animate back arrow to close button in Compose using animated drawables

Animate Back Arrow to Close Icon in Compose This is a simple demo for animated v

Jose Mateo 3 Feb 17, 2022
Trying to play with Jetpack compose low level animations APIs, which are animate*AsState APIs.

ComposeSimpleAnimation Trying to play with Jetpack compose low level animations APIs, which are animate*AsState APIs that I needed in another project.

Mustafa Ibrahim 39 Dec 10, 2022
PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG)

PaintableVectorView PaintableVectorView enables to change color of paths/groups in Vector Drawable (SVG) Demo Car icon made by Prosymbols from www.fla

Jakub Anioła 164 Dec 16, 2022
create your custom themes and change them dynamically with ripple animation

Android Animated Theme Manager create your custom themes and change them dynamically with ripple animation Features support java and kotlin projects.

Iman Dolatkia 601 Dec 22, 2022
ShimmerTextView is a simple library to integrate shimmer effect in your TextView.

ShimmerTextView ShimmerTextView is a simple library to integrate shimmer effect in your TextView. Key features Set a base color in ShimmerTextView. Se

MindInventory 22 Sep 7, 2022