Skip to content

Translation 3D Animation

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

WoWoTranslation3DAnimation

WoWoTranslation3DAnimation provides an animation to change the relative x, y and z values of a view. Notice that setTranslationZ is only available from Lollipop, which means changing z value does not work below Lollipop. WoWoTranslation3DAnimation is similar to WoWoTranslationAnimation.

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

To get the correct values of translation x, y and z, you should add WoWoTranslation3DAnimation after the views-layout jobs happened in activity.

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

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

    // Add animations
}

WoWoTranslation3DAnimation extends XYZPageAnimation and PageAnimation. Check more implementation details in its superclasses.

Methods List of WoWoTranslation3DAnimation.builder()

Clone this wiki locally