This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
AnimationAdapter
nhaarman edited this page Apr 9, 2013
·
1 revision
The AnimationAdapter
class is the base class which handles all animations. You can provide multiple animations when extending this class.
- Create a class
MyAnimationAdapter
which extends theAnimationAdapter
class. - Add the default constructor
MyAnimationAdapter(BaseAdapter, Context)
. - Implement the methods
getAnimators(ViewGroup, View)
,getAnimationDelayMillis()
,getAnimationDurationMillis()
. - Use the
MyAnimationAdapter
class on yourListView
.
public class MyAnimationAdapter extends AnimationAdapter {
public MyAnimationAdapter(BaseAdapter baseAdapter) {
super(baseAdapter);
}
@Override
public Animator[] getAnimators(ViewGroup parent, View view) {
Animator bottomInAnimator = ObjectAnimator.ofFloat(view, "translationY", 500, 0);
Animator rightInAnimator = ObjectAnimator.ofFloat(view, "translationX", parent.getWidth(), 0);
return new Animator[] { bottomInAnimator, rightInAnimator };
}
@Override
protected long getAnimationDelayMillis() {
return DEFAULTANIMATIONDELAYMILLIS;
}
@Override
protected long getAnimationDurationMillis() {
return DEFAULTANIMATIONDURATIONMILLIS;
}
}
This particular example makes the views animate diagonally in from bottom right. This has exact the same result as stacking a SwingBottomInAnimationAdapter
onto a SwingRightInAnimationAdapter
.