Android 循环进度条在进行时变慢
Android circular progress bar slows down at it progresses
我实现了一个在 10 秒内填满的圆形进度条。但是,我认为该条在开始时会更快地填满,结果随着时间的推移它会变慢(填充的动画)。此外,在最后,它停了一会儿,然后终于结束了。我使用的代码是从这里的第一个答案中获得的:
How to Create a circular progressbar in Android which rotates on it?
然后我启动进度条的代码是:
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 100);
animation.setDuration (10000);
animation.setInterpolator (new DecelerateInterpolator());
animation.start();
如何让动画更流畅?
这是因为您正在使用 DecelerateInterpolator
。插值器定义动画的变化率。这使得基本的动画效果可以加速、减速、重复等
您可以阅读有关插值器的更多信息here。
您可以使用 LinearInterpolator or AccelerateInterpolator 满足您的目的。
我实现了一个在 10 秒内填满的圆形进度条。但是,我认为该条在开始时会更快地填满,结果随着时间的推移它会变慢(填充的动画)。此外,在最后,它停了一会儿,然后终于结束了。我使用的代码是从这里的第一个答案中获得的: How to Create a circular progressbar in Android which rotates on it?
然后我启动进度条的代码是:
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt (progressBar, "progress", 0, 100);
animation.setDuration (10000);
animation.setInterpolator (new DecelerateInterpolator());
animation.start();
如何让动画更流畅?
这是因为您正在使用 DecelerateInterpolator
。插值器定义动画的变化率。这使得基本的动画效果可以加速、减速、重复等
您可以阅读有关插值器的更多信息here。
您可以使用 LinearInterpolator or AccelerateInterpolator 满足您的目的。