Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fill progress bar smoothly with animation

I have implemented the progress bar with fill animation, but I would like to have a animation effect like a train and which would fill fast to a particular point and then a bit slow brake in the speed till the end point. My current animation implementation is:

ObjectAnimator animation = ObjectAnimator.ofInt(pbOption, "progress", percent);
animation.setDuration(1250);
animation.setInterpolator(new AccelerateInterpolator());
animation.start();
like image 401
A2N Avatar asked Sep 18 '25 07:09

A2N


1 Answers

Change AccelerateInterpolator() to DecelerateInterpolator(). Here the rate of change starts out quickly and and then decelerates.

   ObjectAnimator animation = ObjectAnimator.ofInt(pbOption, "progress", percent);
            animation.setDuration(1250);
            animation.setInterpolator(new DecelerateInterpolator());
            animation.start();
like image 96
Ajay J G Avatar answered Sep 19 '25 19:09

Ajay J G