Я хотел бы создать анимацию увеличения и уменьшения для моего ImageView, я настроил прослушиватель и установил анимацию RepeatCount в бесконечность.ImageView Увеличить масштаб, уменьшить масштаб бесконечной анимации и onAnimationRepeat issue
Сначала я начинаю с эффекта масштабирования, затем в методе onAnimationRepeat. Я создаю часть уменьшения масштаба, в которой используется логическое значение. Я хотел бы перезапустить весь эффект, снова увеличивая масштаб. Но после первого раза onAnimationRepeat не вызывается снова, в свою очередь анимация повторяется, но она застревает в части уменьшения.
Что мне не хватает?
//image animation
Animation anim = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(10000);
zoomIn = true;
// Start animating the image
final ImageView splash = (ImageView) findViewById(R.id.imageView);
splash.startAnimation(anim);
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
if(zoomIn) {
Log.w("", "we zoom out, and zoomIn is: " + zoomIn);
Animation anim = new ScaleAnimation(1.1f, 1f, 1.1f, 1f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(10000);
splash.startAnimation(anim);
zoomIn = false;
} else if(!zoomIn) {
Log.w("", "we zoom in, and zoomIn is: " + zoomIn);
Animation anim = new ScaleAnimation(1.0f, 1.1f, 1.0f, 1.1f);
anim.setInterpolator(new LinearInterpolator());
anim.setRepeatCount(Animation.INFINITE);
anim.setDuration(10000);
splash.startAnimation(anim);
zoomIn = true;
}
}
});
}
Там должен быть вызов 'scaleAnim.start();' в конец. 'setRepeatCount' и' setRepeatMode' являются методами 'ObjectAnimator', а не' AnimatorSet'. –