1

I have two different AnimatorSet, AnimatorSetX and AnimatorSetY. These animation sets have child animations that have different animation durations.

My purpose is, based on AnimatorSetX's current time, set different time for AnimatorSetY's child animations.

Below approach is working but it sets same playTime for all child animations. I want to give different play times for each child animation.

long currentPlayTime = animatorSetX.getCurrentPlayTime();
animatorSetY.setCurrentPlayTime(currentPlayTime);
animatorSetY.start();

So in order to solve this, Iterated all child animations and set different play times, but somehow it did not work

    List<Animator> animators = animatorSetY.getChildAnimations();
    for (Animator anim : animators) {
        if (anim instanceof ObjectAnimator) {
            ((ObjectAnimator) anim).setCurrentPlayTime(currentAnimationPlayTime);
        } else if (anim instanceof ValueAnimator) {
            ((ValueAnimator) anim).setCurrentPlayTime(currentAnimationPlayTime);
        }
    }

I could not figure out why it is not working? Any one can help or give me a clue?

4

0 回答 0