AndroidViewAnimations
AndroidViewAnimations copied to clipboard
How to chain animations?
You could use Listeners:
YoYo.with(Techniques.FadeIn).duration(250)
.withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
// Start new animation here
}
@Override
public void onAnimationCancel(Animator animation) {}
@Override
public void onAnimationRepeat(Animator animation) {
// This is being called when the animation starts over, I guess
}
})
.playOn(lyt_ProgressBarOverlay);
I know this, but it would be great to have a set of animations played on a single view one after another or together.
@mori-honest I agree, something like a choregrapher where you put together multiple animations, be it chained or in parallel would be nice.
@mori-honest Exactly using set of animations would be much usable rather than applying a single animation effect.
With the most recent AndroidAnimations version you have to import Animator from android.animations.Animator.
Or use chain for events like this:
YoYo.with(Techniques.FadeIn).duration(250).onStart(new YoYo.AnimatorCallback() {
@Override
public void call(Animator animator) {
pbSmoothProgressBar.setVisibility(View.VISIBLE);
}
}).playOn(pbSmoothProgressBar);
`private void animateButtonsChain(final View[] views, final Techniques technique, final boolean isShow) { animate(views[0], technique, isShow, new OnClickListener() { int counter = 1; @Override public void onClick(View view) { if (counter < views.length ) animate(views[counter++], technique, isShow, this); } }); }
private void animate(final View v, Techniques t, final boolean isShow, final OnClickListener l) {
YoYo.with(t).withListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
if (isShow)
v.setVisibility(VISIBLE);
}
@Override
public void onAnimationEnd(Animator animator) {
if (!isShow)
v.setVisibility(GONE);
l.onClick(v);
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
}).repeat(0).duration(150).playOn(v);
}`