WHOATEMYNOODLES
WHOATEMYNOODLES

Reputation: 897

TextView - Animation for decreasing numbers

I'm trying to create an animation for a TextView where the numbers decrease/increase like this:

enter image description here

How would I do something like this? Is there a library that anyone knows of?

Upvotes: 1

Views: 678

Answers (1)

WHOATEMYNOODLES
WHOATEMYNOODLES

Reputation: 897

Using ValueAnimator:

private void startCountAnimation() {
    ValueAnimator animator = ValueAnimator.ofInt(0, 600);
    animator.setDuration(5000);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        public void onAnimationUpdate(ValueAnimator animation) {
            textView.setText(animation.getAnimatedValue().toString());
        }
    });
    animator.start();
}

https://stackoverflow.com/a/29443935/11628353

Upvotes: 1

Related Questions