2012-08-17 5 views
7

Ich habe benutzerdefinierte Animation für die Fragmenttransaktion mit fragmentTansaction.setCustomAnimation (in, out) festgelegt. Ich möchte Anfang und Ende der Animation wissen und entsprechende Aktionen auslösen. Wie kann ich das machen? Ist es möglich einen Listener zu setzen?Animation Listener für benutzerdefinierte Animation

+0

dieses Themas sehen, vielleicht hilft Ihnen zu klären: http://stackoverflow.com/questions/8937036/what-is-the-difference -between-bitmap-and-drawable-in-android –

+0

Überprüfen Sie diese, hoffe es hilft http://stackoverflow.com/questions/19614392/fragmenttransaction-before-and-after-setcustomanimation-callback – oalpayli

Antwort

0

Sie können Animation verwenden in onStart() für 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(); 
     } 

    }