Skip to content

Background Color Animation

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

WoWoBackgroundColorAnimation changes the background color of a view by calling its setBackgroundColor method. Check the demo activity for more details.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addAnimations(findViewById(R.id.test1), Chameleon.RGB);
    addAnimations(findViewById(R.id.test2), Chameleon.HSV);
}

private void addAnimations(View view, Chameleon chameleon) {
    ViewAnimation viewAnimation = new ViewAnimation(view);
    viewAnimation.add(WoWoBackgroundColorAnimation.builder().page(0)
            .from("#ff0000").to("#00ff00").chameleon(chameleon).build());
    viewAnimation.add(WoWoBackgroundColorAnimation.builder().page(1)
            .from("#00ff00").to("#0000ff").chameleon(chameleon).build());
    viewAnimation.add(WoWoBackgroundColorAnimation.builder().page(2)
            .from("#0000ff").to("#ff0000").chameleon(chameleon).build());
    viewAnimation.add(WoWoBackgroundColorAnimation.builder().page(3).start(0).end(0.5)
            .from("#ff0000").to("#000000").chameleon(chameleon).build());
    viewAnimation.add(WoWoBackgroundColorAnimation.builder().page(3).start(0.5).end(1)
            .from("#000000").to("#ff0000").chameleon(chameleon).build());
    wowo.addAnimation(viewAnimation);
    
    wowo.setEase(ease);
    wowo.setUseSameEaseBack(useSameEaseTypeBack);
    wowo.ready();
}

As mentioned in TextView TextColor Animation, every animation that extends from SingleColorPageAnimation and MultiColorPageAnimation has a parameter named Chameleon which performs the discoloration job. Check Chameleon Wiki to know about the difference between RGB and HSV discoloration-styles and how they works.

WoWoBackgroundColorAnimation extends SingleColorPageAnimation and PageAnimation. Check more implementation details in its superclasses.

Methods List of WoWoBackgroundColorAnimation.builder()

Clone this wiki locally