2012-08-17 73 views
7

我已經使用fragmentTansaction.setCustomAnimation(in,out)爲片段事務設置了自定義動畫。我想知道動畫的開始和結束,並觸發一些相應的操作。我怎樣才能做到這一點?是否可以設置一些列表程序?自定義動畫的動畫監聽器

+0

看到這個線索,或許可以幫助你澄清:http://stackoverflow.com/questions/8937036/what-is-the-difference位圖和繪製在Android中 – 2012-08-17 07:50:58

+0

檢查了這一點,希望它有幫助 http://stackoverflow.com/questions/19614392/fragmenttransaction-before-and-after-setcustomanimation-callback – oalpayli 2015-12-28 09:53:52

回答

0

您可以在onStart()使用動畫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(); 
     } 

    }