Skip to content

Typewriter

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

Typewriter interface is used to change text from fromText or toText or in reverse by offset(0<=offset<=1).

String type(String fromText, String toText, float offset);

In the builder of TextPageAnimation, you can define a custom typewriter to make a funny text transformation. For example:

wowo.addAnimation(view)
        .add(WoWoTextViewTextAnimation.builder().page(0)
                .from("Nightonke").to("WoWoViewPager").typewriter(new Typewriter() {
                    @Override
                    public String type(String fromText, String toText, float offset) {
                        if (0 < offset && offset < 1) return "Typing...";
                        else if (offset == 0) return fromText;
                        else return toText;
                    }
                }).build());

Or just use the default typewriter implementations in WoWoTypewriter:

/**
 * ABC->123:
 * ABC->AB->A->{empty}->1->12->123
 */
WoWoTypewriter.DeleteThenType;

/**
 * ABC->123:
 * ABC->1AB->12A->123
 */
WoWoTypewriter.InsertFromLeft;

/**
 * ABC->123:
 * ABC->AB1->A12->123
 */
WoWoTypewriter.InsertFromRight;