valueanimator intent animations animate activities android animation objectanimator

android - intent - Comprobar si AnimatorSet ha terminado la animación?



intent transition animation android (2)

Intento animar botones con fade in animation usando AnimatorSet

Button fades in > Click button > Remaining buttons fade out

Para hacer esto, quiero configurar onClickListner after the animation is completed , pero eso no parece funcionar. Al hacer clic en un botón en el medio de la animación se triggers the onClick action :

setQuestion = new AnimatorSet(); setQuestion.playSequentially(fadeinAnimationQ,fadeinAnimation1,fadeinAnimation2,fadeinAnimation3,fadeinAnimation4,fadeinAnimation5); setQuestion.start();

Este es el método que verifica if the animation has finished .

private void checkAnimation() { while (true) { // Check if animation has ended if (setQuestion.isRunning() == false) { assignListners(); break; } } }


Estaba teniendo un problema similar y así es como lo resolví:

private void crossFadeAnimation(final View fadeInTarget, final View fadeOutTarget, long duration){ AnimatorSet mAnimationSet = new AnimatorSet(); ObjectAnimator fadeOut = ObjectAnimator.ofFloat(fadeOutTarget, View.ALPHA, 1f, 0f); fadeOut.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { fadeOutTarget.setVisibility(View.GONE); } @Override public void onAnimationCancel(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } }); fadeOut.setInterpolator(new LinearInterpolator()); ObjectAnimator fadeIn = ObjectAnimator.ofFloat(fadeInTarget, View.ALPHA, 0f, 1f); fadeIn.addListener(new Animator.AnimatorListener() { @Override public void onAnimationStart(Animator animation) { fadeInTarget.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animator animation) {} @Override public void onAnimationCancel(Animator animation) {} @Override public void onAnimationRepeat(Animator animation) {} }); fadeIn.setInterpolator(new LinearInterpolator()); mAnimationSet.setDuration(duration); mAnimationSet.playTogether(fadeOut, fadeIn); mAnimationSet.start(); }


Puede configurar AnimatorListener en fadeinAnimation5. Esto le dará una devolución de llamada onAnimationEnd.

fadeinAnimation5.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { // ... } @Override public void onAnimationRepeat(Animator animation) { // ... } @Override public void onAnimationEnd(Animator animation) { // ... } @Override public void onAnimationCancel(Animator animation) { // ... } });

O, como lo sugiere Slott, use un AnimatorListenerAdapter

fadeinAnimation5.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { // ... } }