我想“闪烁”一个视图 3 倍(缩小和备份,重复 3 倍)。它有效,但不适用于 AnimatorSet。
这有效:
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() {
}
});
}
});
}
});
}
});
}
});
}
});
但这不会:
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);
我错过了什么?我只想改进第一个代码块,因为它看起来很丑。