2012-08-17 22 views
7

Ho impostato l'animazione personalizzata per la transazione di frammento utilizzando fragmentTansaction.setCustomAnimation (in, out). Voglio conoscere l'inizio e la fine dell'animazione e attivare alcune rispettive azioni. Come lo posso fare? È possibile impostare un listener?Listener di animazione per animazione personalizzata

+0

Vedere questa discussione, forse aiuta a chiarire: http://stackoverflow.com/questions/8937036/what-is-the-difference -tra-bitmap-and-drawable-in-android –

+0

Controlla, Speriamo che aiuti http://stackoverflow.com/questions/19614392/fragmenttransaction-before-and-after-setcustomanimation-callback – oalpayli

risposta

0

È possibile utilizzare l'animazione in onStart() per getDecorView()

@Override 
    public void onStart() { 
     super.onStart(); 

     if (getDialog().getWindow().getDecorView()) { 
      ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(getDialog().getWindow().getDecorView(), 
        PropertyValuesHolder.ofFloat(View.Y, 0, 1000)); 
      objectAnimator.setDuration(1000); 
      objectAnimator.addListener(new Animator.AnimatorListener() { 
       @Override 
       public void onAnimationStart(Animator animation) { 

       } 

       @Override 
       public void onAnimationEnd(Animator animation) { 

       } 

       @Override 
       public void onAnimationCancel(Animator animation) { 

       } 

       @Override 
       public void onAnimationRepeat(Animator animation) { 

       } 
      }); 
      objectAnimator.start(); 
     } 

    } 
Problemi correlati