-
Notifications
You must be signed in to change notification settings - Fork 451
Shape Color Animation
Weiping Huang edited this page Apr 6, 2017
·
3 revisions
WoWoShapeColorAnimation provides an animation to change the color of shape-drawable of a view. The background drawable must be a GradientDrawable
, which should look like the following code in .xml file:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval" >
<solid android:color="@color/red"/>
</shape>
Then in activity file:
@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(WoWoShapeColorAnimation.builder().page(0)
.from("#ff0000").to("#00ff00").chameleon(chameleon).build());
viewAnimation.add(WoWoShapeColorAnimation.builder().page(1)
.from("#00ff00").to("#0000ff").chameleon(chameleon).build());
viewAnimation.add(WoWoShapeColorAnimation.builder().page(2)
.from("#0000ff").to("#ff0000").chameleon(chameleon).build());
viewAnimation.add(WoWoShapeColorAnimation.builder().page(3).start(0).end(0.5)
.from("#ff0000").to("#000000").chameleon(chameleon).build());
viewAnimation.add(WoWoShapeColorAnimation.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.
WoWoShapeColorAnimation extends SingleColorPageAnimation and PageAnimation. Check more implementation details in its superclasses.
Basic Animations
- Position Animation
- Position 3D Animation
- Translation Animation
- Translation 3D Animation
- Scale Animation
- Alpha Animation
- Rotation Animation
- Elevation Animation
TextView Animations
Color Animations
- Background Color Animation
- Shape Color Animation
- State-List Color Animation
- Layer-List Color Animation
Interface Expansibility