В Kotlin вы можете использовать 2 функции расширения, чтобы помочь с этим, увеличивая 1 на 1 по мере выполнения. Таким образом, вы можете получить более плавную анимацию:
/**
* ProgressBar Extensions
*/
fun ProgressBar.setBigMax(max: Int) {
this.max = max * 1000
}
fun ProgressBar.animateTo(progressTo: Int, startDelay: Long) {
val animation = ObjectAnimator.ofInt(
this,
"progress",
this.progress,
progressTo * 1000
)
animation.duration = 500
animation.interpolator = DecelerateInterpolator()
animation.startDelay = startDelay
animation.start()
}
Как это использовать:
progress.setBigMax(10)
progress.animateTo(10, 100)