Android動畫之AnimationListener(六)

通過AnimationListener可以監聽Animation的運行過程

[java]
AnimationSet as=new AnimationSet(true); 
            RotateAnimation al=new RotateAnimation(0,-720,Animation.RELATIVE_TO_PARENT,0.5f,Animation.RELATIVE_TO_PARENT,0.5f); 
            al.setDuration(3000); 
            al.setAnimationListener(new AnimationListener(){ 
 
                public void onAnimationStart(Animation animation) { 
                    // TODO Auto-generated method stub  
                     
                } 
 
                public void onAnimationEnd(Animation animation) { 
                    // TODO Auto-generated method stub  
                     
                } 
 
                public void onAnimationRepeat(Animation animation) { 
                    // TODO Auto-generated method stub  
                     
                } 
                 
            }); 
            as.addAnimation(al); 
            iv.startAnimation(as); 

AnimationSet as=new AnimationSet(true);
   RotateAnimation al=new RotateAnimation(0,-720,Animation.RELATIVE_TO_PARENT,0.5f,Animation.RELATIVE_TO_PARENT,0.5f);
   al.setDuration(3000);
   al.setAnimationListener(new AnimationListener(){

    public void onAnimationStart(Animation animation) {
     // TODO Auto-generated method stub
     
    }

    public void onAnimationEnd(Animation animation) {
     // TODO Auto-generated method stub
     
    }

    public void onAnimationRepeat(Animation animation) {
     // TODO Auto-generated method stub
     
    }
    
   });
   as.addAnimation(al);
   iv.startAnimation(as);有三個方法分別是Animation開始的時候調用,完成的時候調用,重復的時候調用。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。