Code example for AnimatorSet

Methods: cancel, start

0
 
        findViewById(R.id.start_animation).setOnClickListener(new View.OnClickListener() {
 
            @Override 
            public void onClick(View v) {
                animatorSet2.cancel();
                animatorSet2.start();// 动画没有结束,不能重新开始,对于无限循环的动画如果要重新开始需要手动调用cancel
                animatorSet.cancel();
                animatorSet.start();
            } 
        }); 
    } 
 
    private AnimatorSet createAnimatorSet1() {
        ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(mImage1, View.ROTATION, 0, 360);
        rotationAnimator.setDuration(100);
        // rotationAnimator.setRepeatMode(11); 
        rotationAnimator.setRepeatCount(ObjectAnimator.INFINITE);
 
        PropertyValuesHolder pvhSx = PropertyValuesHolder.ofFloat(View.SCALE_X, 1, 1.5f);
        PropertyValuesHolder pvhSy = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1, 1.5f);