我正在尝试使用对象动画师为视图设置颜色,但它不会改变颜色。她是代码示例
self._Nfeat=[[0]*numFeatures]*numClasses
我没有在按钮中添加对象动画对象?
答案 0 :(得分:1)
尝试使用此方法为View的背景颜色设置动画 -
public static void animateImageViewBackground(final View viewToAnimate, int colorFrom, int colorTo, int animationDuration)
{
ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
colorAnimation.setDuration(animationDuration);
colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
int newColor = (int) animator.getAnimatedValue();
viewToAnimate.setBackgroundColor(newColor);
}
});
colorAnimation.start();
}