Skip to content

Interface Animation

Weiping Huang edited this page Apr 6, 2017 · 2 revisions

We have discussed about how to customize an animation in Custom Animation Wiki. But if the demand you need is quite easy, you don't have to do so much job. WoWoInterfaceAnimation changes the offset value of an object that implements the WoWoAnimationInterface. For example, if we just simply wanna change the text of a TextView, we can:

wowo.addAnimation(textView)
        .add(WoWoInterfaceAnimation.builder().page(0).implementedBy(new WoWoAnimationInterface()
            @Override
            public void toStartState() {
                textView.setText("Elevation 0");
            }
            @Override
            public void toMiddleState(float offset) {
                textView.setText("Elevation " + offset);
            }
            @Override
            public void toEndState() {
                textView.setText("Elevation 1");
            }
        }).build());

And if you wanna custom some views which can perform an animation with WoWoViewPager, you can implements WoWoAnimationInterface too:

public class SomeView extends View implements WoWoAnimationInterface {
    @Override
    public void toStartState() {
        setProcess(0);
    }

    @Override
    public void toMiddleState(float offset) {
        if (offset < 0) offset = 0;
        if (offset > 1) offset = 1;
        setProcess(offset);
    }

    @Override
    public void toEndState() {
        setProcess(1);
    }
}

Then SomeView is ready to be used by WoWoInterfaceAnimation. The examples in WoWoViewPager are the WoWoGifView and WoWoSvgView. They provide animations for gifs and svgs. Check SVG Animation Wiki and GIF Animation Wiki for more details.