我想为我的ImageView构建一个放大和缩小动画,我设置了一个监听器并将动画RepeatCount设置为无限。
首先我以放大效果开始,然后在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;
}
}
});
}
答案 0 :(得分:3)
只需切换到ObjectAnimator并使用以下内容:
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 1.0f, 1.1f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 1.0f, 1.1f);
AnimatorSet scaleAnim = new AnimatorSet();
scaleAnim.setDuration(10000);
scaleAnim.play(scaleX).with(scaleY);
scaleAnim.setRepeatCount(ObjectAnimator.INFINITE);
scaleAnim.setRepeatMode(ObjectAnimator.RESTART/REVERSE...);
答案 1 :(得分:3)
顺序查看图像视图
compile 'org.apache.flink:flink-java:1.0.0-hadoop1'