final int[] ids = {R.drawable.icon1,R.drawable.icon2,R.drawable.icon3};
valueAnimator = android.animation.ValueAnimator.ofInt(0, ids.length - 1).setDuration(1000);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.addUpdateListener(new android.animation.ValueAnimator.AnimatorUpdateListener() {
int i = -1;
@Override
public void onAnimationUpdate(android.animation.ValueAnimator animation) {
int animatedValue = (int) animation.getAnimatedValue();
if(i!=animatedValue) {
_fab.setImageDrawable(getResources().getDrawable(ids[animatedValue]));
i = animatedValue;
}
}
});
}
private android.animation.ValueAnimator valueAnimator;
public void nothing() {
//Use it on Button to reverse animator
valueAnimator.reverse();
Komentar