1. 程式人生 > >Android Animation 幀動畫監聽結束的方法

Android Animation 幀動畫監聽結束的方法

  1. public void mmswoon(){  
  2.         imageView.setBackgroundResource(R.anim.mmswoon);  
  3.         AnimationDrawable animationDrawable = (AnimationDrawable)imageView.getBackground();  
  4.         animationDrawable.start();  
  5.         int duration = 0;  
  6.         for(int i=0;i<animationDrawable.getNumberOfFrames();i++){  
  7.             duration += animationDrawable.getDuration(i);  
  8.         }  
  9.         Handler handler = new Handler();  
  10.         handler.postDelayed(new Runnable() {  
  11.             public void run() {  
  12.                //此處呼叫第二個動畫播放方法     
  13.             }  
  14.         }, duration);  
  15.     }