我正在尝试做一个ProgressWheel,它的颜色会随着车轮的填充而改变(车轮以0%的绿色开始,在100%的时候完成红色,随着时间的推移,所有的车轮都变成红色:而不是彩虹)。因此,我使用的是一个ObjectAnimator,车轮采取的颜色,但我不能设法使它改变颜色随着时间.
final ObjectAnimator animator = ObjectAnimator.ofInt(progressBar, "barColor", Color.GREEN, Color.RED);
animator.setDuration(remainingTime);
animator.setEvaluator(new ArgbEvaluator());
animator.setInterpolator(new DecelerateInterpolator(2));
animator.start();有什么想法吗?
发布于 2014-09-17 06:56:40
我最终做到了这一点(它来自StackOverflow上的另一篇文章):
final ObjectAnimator colorAnimator = ObjectAnimator.ofObject(progressBar, "barColor", new ArgbEvaluator(), green, red);
colorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
progressBar.refreshWheel();
}
});
colorAnimator.setInterpolator(new DecelerateInterpolator());
colorAnimator.setDuration(remainingTime);
colorAnimator.start();在ProgressWheel.java中
public void refreshWheel() {
setupPaints();
}https://stackoverflow.com/questions/25812574
复制相似问题