Skip to content

Translation Animation

Weiping Huang edited this page Apr 5, 2017 · 4 revisions

WoWoTranslationAnimation

WoWoTranslationAnimation changes the translation x, y values of a view with methods setTranslationX and setTranslationY. Different with WoWoPositionAnimation, the x, y values here is relative to the original ones.

viewAnimation.add(WoWoTranslationAnimation.builder().page(0)
        .fromX(view.getTranslationX()).toX(-screenW / 2 + radius)
        .fromY(view.getTranslationY()).toY(-screenH / 2 + radius)
        .ease(ease).build());

Similar to WoWoPositionAnimation, the animation-adding job is better to do after when the views-layout happened. So in the WoWoTranslationAnimationActivity as a demo, I put the code in onWindowFocusChanged methods:

@Override
public void onWindowFocusChanged(boolean hasFocus) {
    super.onWindowFocusChanged(hasFocus);
    addAnimations();
}

private void addAnimations() {
    // Prevent duplicate adding
    if (animationAdded) return;
    animationAdded = true;

    // Add animations
}

WoWoTranslationAnimation extends XYPageAnimation and PageAnimation. Check more implementation details in its superclasses.

Methods List of WoWoTranslationAnimation.builder()

You can’t perform that action at this time.