ActionAnimatorSet
?????????????
???????????????????????????????????A????????B?C?????A??????????????B????Android?SDK???AnimationSet???????????????? ActionAnimatorSet??????????????????????????????????
##????
compile 'com.paulyung:actionanimatorset:1.1.1'
##????
##?AnimatorSet???
?? playTogether()
????????? playSequence()
????????????
##?AnimatorSet???
- 1 ????????
Animator.AnimatorListener
????????????????????addStartAction(Animator anim, Action start)
?addEndAction(Animator anim, Action end)
???????????????????Action
???????? - 2 ???????????????????????????????
##????ActionAnimatorSet
AnimatorManager manager = new DefaultAnimatorManager();
ActionAnimatorSet animSet = manager.createAnimatorSet();
##AnimatorManager ??????????????????? ActionAnimatorSet
??????????????????Tag???????????????????????????????
AnimatorManager manager = new DefaultAnimatorManager();
ObjectAnimator animA = ObjectAnimator.ofFloat(view1, "y", 1200);
manager.addAnimator(animA, "animA");
manager.setOnStartListener("animA", new Action() {
@Override
public void doAction() {
showToast("view1???");
}
}
);
manager.build();
//?????????????? /// manager.start("animA")
##ActionAnimatorSet???????
void playFirst(Animator... anims)//???????? void playTogether(Animator... anims)//??????playFirst?????? void playSequence(Animator... anims)//???? void addAnimWith(Animator A, Animator B)//?A???????B???????????????????????????? void addAnimAfter(Animator A, Animator B)//?A???????B?????????? void addAnimBetween(Animator A, Animator B, TriggerPoint startPoint)//?A??????????????TriggerPoint ??B????????????A void addStartAction(Animator A, Action start);
//?A???????????? void addEndAction(Animator A, Action end);
//?A????????????
##???????
? ActionAnimatorSet?????????????????????????????????????????????????????
###??1????????? ??? ObjectAnimatior
??3????A?B?C
ObjectAnimator A = ObjectAnimator.ofFloat(view1, "y", 1200);
ObjectAnimator B = ObjectAnimator.ofFloat(view2, "y", 1200);
ObjectAnimator C = ObjectAnimator.ofFloat(view3, "y", 1200);
???? ActionAnimatorSet
??? playTogether()
???? playFirst()
?????? ActionAnimatorSet
ActionAnimatorSet animSet = new ActionAnimatorSet();
animSet.playTogether(view1Anim, view2Anim, view3Anim);
animSet.start()//??????????
###??2?????? ????????A?B?C????????? A??????A??????B?C????
animSet.playFirst(A);
//A???????? animSet.addAnimAfter(B, A);
//?B???ActionAnimatorSet???A???????? animSet.addAnimAfter(C, A);
//?C???ActionAnimatorSet???A???????? animSet.start()//??????????
????????????????????C???B?????A???????????????
###??3????????? A????B?A????600??????C?B??600????
animSet.playFirst(A);
//A???????? animSet.addAnimBetween(B, A, new TriggerPoint(600));
animSet.addAnimBetween(C, B, new TriggerPoint(600));
???????????? Float
???????? Int
??????????????????
###??4???????????Object???? ??A????????? PointF
?????????????
PointF startPoint = new PointF(100, 200);
PointF endPoint = new PointF(400, 500);
ObjectAnimator A = ObjectAnimator.ofObject(this, "Anim", new AnimEvaluator(), startPoint, endPoint);
//????set?????Activity???????????this
B?C???Float???????????? ??A????????? startPoint
? endPoint
??????? x
??300??????????B?C????????
animSet.playFirst(A);
//A???????? animSet.addAnimBetween(B, A, new TriggerPoint<PointF>() {
@Override
public boolean whenToStart(PointF p) {
return p.x > 300;
}
}
);
//??B??A???PointF?x??300????? animSet.addAnimWith(C, B);
//??C??B????
##????
TriggerPoint????????????????????????????????????? Object
???????Vaule
-
1 ?ObjectAnimator?Value?Int??float??????????????????????? eg:
new TriggerPoint(0.3);
-
2 ?ObjectAnimator?Value?????????
TriggerPoint
???????whenToStart(T obj)
?????????????????????????boolean
?????true
????????????TriggerPoint
????????????
##?? ??????Sample??