Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android動畫之AnimationListener(六)

Android動畫之AnimationListener(六)

編輯:關於Android編程

通過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開始的時候調用,完成的時候調用,重復的時候調用。

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved