How to make a circle progress is running smoothly like Timer of Android OS buy using Kotlin Flow

vegeta
2 min readMar 24, 2021

Progress circle, I’m addicted to customize progress bar on Android so I’d like to write something about that.

First of all, let see how does Timer work in Android OS.
One can say that it’s working fine and running smoothly :)

Timer of Android OS

The first approach I was implemented is that using repeat{ } then emit a decreasing the sequence of seconds. Basically, It worked as expected but the circle progress is not running smoothly.
Let’s see the code:

Repository class

ViewModel class

CountDown 10 sec

So, how to make the circle run smoothly ? The point is that you need make a progress is finer. Instead of repeat by 10, you have to repeat by 10 * 100 times
and delays at short interval !!!
Here is the code after improvement.

And the result as below

Finish code

Do you think it’s running smoothly? If you need full source code, comment below then I will share !!!

Happy coding !

--

--