img1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// ObjectAnimator//动画的执行类
// .ofFloat(view, "rotationY", 0.0F, 360.0F)
// .setDuration(5000)//动画持续时间
// .start();
//多个动画一起执行
// ObjectAnimator anim1 = ObjectAnimator.ofFloat(view, "scaleX",
// 1.0f, 2f);
// ObjectAnimator anim2 = ObjectAnimator.ofFloat(view, "scaleY",
// 1.0f, 2f);
// ObjectAnimator anim3 = ObjectAnimator.ofFloat(view, "rotationY", 0.0f, 360.0f);
// AnimatorSet animSet = new AnimatorSet();
// animSet.setDuration(2000);
// // animSet.setInterpolator(new LinearInterpolator());
// //三个动画同时执行
// animSet.playTogether(anim1, anim2, anim3);
// animSet.start();
//ValueAnimation
// ValueAnimator anim = ValueAnimator.ofFloat(0f, 100f);
// anim.setRepeatMode(ValueAnimator.REVERSE);
// anim.setRepeatCount(2);
// anim.setDuration(3000);
// anim.setTarget(view);
// anim.start();
//淡入淡出
anim1 = ObjectAnimator
.ofFloat(view, "alpha", 1f, 0f, 1f)
.setDuration(5000);
//以Y轴旋转
anim2 = ObjectAnimator
.ofFloat(view, "rotationY", 0.0F, 360.0F)
.setDuration(5000);
//大小调整
anim3 = ObjectAnimator
.ofFloat(view, "scaleY", 1.0f, 2f)
.setDuration(5000);
anim4 = ObjectAnimator
.ofFloat(view, "scaleX", 1.0f, 2f)
.setDuration(5000);
anim5 = ObjectAnimator
.ofFloat(view, "rotationX", 360.0F, 0.0F)
.setDuration(5000);
// 播放anim1;
// 同时播放anim2,anim3,anim4;
// 播放anim5。
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(anim1).before(anim2);
bouncer.play(anim2).with(anim3);
bouncer.play(anim2).with(anim4);
bouncer.play(anim5);
bouncer.start();
}
});
}
属性动画
最新推荐文章于 2022-12-28 16:19:02 发布