Android ObjectAnimator不调用onAnimationStart方法

先看代码

动画效果是从小变大,同时透明度从完全透明变成完全不透明;

		ObjectAnimator rotateX = ObjectAnimator.ofFloat(view01, "scaleX", 0.0f, 1f);
        ObjectAnimator rotateY = ObjectAnimator.ofFloat(view01, "scaleY", 0.0f, 1f);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(view01, "alpha", 0.0f, 1f);
        AnimatorSet animSet2 = new AnimatorSet();
        animSet2.play(rotateX).with(rotateY).with(alpha);
        animSet2.setDuration(800);
        animSet2.setStartDelay(500);
        animSet2.start();
         animSet2.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
            }
        });

执行结果是onAnimationEnd方法可以执行,但onAnimationStart方法不能执行,原因是先执行方法start()然后才执行方法addListener();只需将方法addListener()放置在方法start()之前即可;

注意:
代码中有一个方法setStartDelay(500);此方法意为500毫秒后在执行动画;

你可能感兴趣的:(android)