I want to "blink" a view 3x (scale down and back up, repeat 3x). It works, but not with AnimatorSet.
This works:
ibOffers.animate().scaleX(0.7f).scaleY(0.7f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
ibOffers.animate().scaleX(1.0f).scaleY(1.0f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
ibOffers.animate().scaleX(0.7f).scaleY(0.7f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
ibOffers.animate().scaleX(1.0f).scaleY(1.0f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
ibOffers.animate().scaleX(0.7f).scaleY(0.7f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
ibOffers.animate().scaleX(1.0f).scaleY(1.0f).setDuration(200).withEndAction(new Runnable() {
@Override
public void run() {
}
});
}
});
}
});
}
});
}
});
}
});
But this doesn't:
final ObjectAnimator scaleDownAnimation =
ObjectAnimator.ofPropertyValuesHolder(ibOffers,
PropertyValuesHolder.ofFloat(View.SCALE_X,0.7f),
PropertyValuesHolder.ofFloat(View.SCALE_Y,0.7f))
.setDuration(200);
final ObjectAnimator scaleBackAnimation =
ObjectAnimator.ofPropertyValuesHolder(ibOffers,
PropertyValuesHolder.ofFloat(View.SCALE_X,1f),
PropertyValuesHolder.ofFloat(View.SCALE_Y,1f))
.setDuration(200);
AnimatorSet s = new AnimatorSet();
s.playSequentially(scaleDownAnimation,
scaleBackAnimation,
scaleDownAnimation,
scaleBackAnimation,
scaleDownAnimation,
scaleBackAnimation);
What am I missing? I just want to improve the first code block as it looks ugly.