激活Paint对象的颜色 [英] Animate color of Paint object
本文介绍了激活Paint对象的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在自定义视图中为颜色之间的Paint
对象设置动画.但是动画不起作用.
I am trying to animate a Paint
object in my custom view between colors. But the animation is not working.
ObjectAnimator colorFade = ObjectAnimator.ofObject(mCirclePaint, "color", new ArgbEvaluator(), getColor(), 0xff000000);
colorFade.setDuration(1500);
colorFade.start();
invalidate();
我以前是这样设置油漆颜色的:
I have previously set the paints color like this:
mCirclePaint.setColor(Color.RED);
更新我认为Handler
对于是否动画没有影响.即使没有处理程序,我也无法为绘画对象设置动画.
UPDATE I don't think the Handler
makes a difference to whether it animated or not. Even without the Handler I cannot animate the paint object.
推荐答案
这是我找到的解决方案:
This is the solution I found:
ObjectAnimator colorFade = ObjectAnimator.ofObject(mCirclePaint, "color", new ArgbEvaluator(), getColor(), mColors[randomNum]);
colorFade.setDuration(1500);
colorFade.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// TODO Auto-generated method stub
invalidate();
}
});
colorFade.start();
这篇关于激活Paint对象的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文