AnimatorSet提供了一个把多个动画组合成一个组合的机制,并可设置组中动画的时序关系,如同时播放,顺序播放等等。
下面的例子可以动画一个接着一个进行播放:
public void move(View view ){
ImageView imageView=(ImageView)findViewById(R.id.imageView);
ObjectAnimator animator1=ObjectAnimator.ofFloat(imageView, "rotation", 0,360f);
ObjectAnimator animator2=ObjectAnimator.ofFloat(imageView, "translationX", 0,200f);
ObjectAnimator animator3=ObjectAnimator.ofFloat(imageView, "translationY", 0,200f);
AnimatorSet set=new AnimatorSet();
//set.playTogether(animator1,animator2,animator3);
set.playSequentially(animator1,animator2,animator3);
set.setDuration(1000);
set.start();
}
而 AnimationSet里面的动画,只能够同时执行。