首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >托德·戴维斯(Todd) ObjectAnimator on ProgressWheel

托德·戴维斯(Todd) ObjectAnimator on ProgressWheel
EN

Stack Overflow用户
提问于 2014-09-12 16:15:28
回答 1查看 213关注 0票数 1

我正在尝试做一个ProgressWheel,它的颜色会随着车轮的填充而改变(车轮以0%的绿色开始,在100%的时候完成红色,随着时间的推移,所有的车轮都变成红色:而不是彩虹)。因此,我使用的是一个ObjectAnimator,车轮采取的颜色,但我不能设法使它改变颜色随着时间.

代码语言:javascript
复制
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();

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-17 06:56:40

我最终做到了这一点(它来自StackOverflow上的另一篇文章):

代码语言:javascript
复制
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中

代码语言:javascript
复制
public void refreshWheel() {
    setupPaints();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25812574

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档