view

  1. import android.view.View;  
  2. import android.view.animation.AlphaAnimation;  
  3. import android.view.animation.Animation;  
  4. import android.view.animation.Animation.AnimationListener;  
  5. import android.view.animation.AnimationSet;  
  6. import android.view.animation.LinearInterpolator;  
  7. import android.view.animation.RotateAnimation;  
  8. import android.view.animation.ScaleAnimation;  
  9. import android.view.animation.TranslateAnimation;  
  10.   
  11.   

  12. public class AnimationEffect  
  13. {  
  14.  
  15.     public static void AddAlphaAni(View view)  
  16.     {  
  17.         AddAlphaAni(view, 011000, Animation.REVERSE, Animation.INFINITE);  
  18.     }  
  19.       
  20.  
  21.     public static void AddAlphaAni(View view, float fromAlpha, float toAlpha, long durationMillis, int repeatMode, int repeatCount)  
  22.     {  
  23.         AlphaAnimation alphaAni = new AlphaAnimation(fromAlpha, toAlpha);  
  24.         alphaAni.setDuration(durationMillis);   
  25.         alphaAni.setRepeatMode(repeatMode);     
  26.         alphaAni.setRepeatCount(repeatCount);   
  27.           
  28.         view.startAnimation(alphaAni);  
  29.     }  
  30.       
  31.   
  32.     public static void setTransAni(View view, int x0, int x1, int y0, int y1, long durationMillis)  
  33.     {  
  34.         TranslateAnimation transAni = new TranslateAnimation(x0, x1, y0, y1);  
  35.         transAni.setDuration(durationMillis);  
  36.         transAni.setRepeatMode(Animation.REVERSE);  
  37.         transAni.setRepeatCount(Animation.INFINITE);  
  38.           
  39.         view.startAnimation(transAni);  
  40.     }  
  41.       
  42.   
  43.     public static void setRotateAni(View view, float fromDegrees, float toDegrees, long time)  
  44.     {  
  45.         setRotateAni(view, fromDegrees, toDegrees, time, Animation.REVERSE, Animation.INFINITE, true);  
  46.     }  
  47.       
  48.  
  49.     public static void setRotateAni(View view, float fromDegrees, float toDegrees, long durationMillis, int repeatModes, int repeatCount, boolean linear)  
  50.     {  
  51.         RotateAnimation rotateAni = new RotateAnimation(fromDegrees, toDegrees, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);  
  52.         rotateAni.setDuration(durationMillis);  
  53.         rotateAni.setRepeatMode(repeatModes);  
  54.         rotateAni.setRepeatCount(repeatCount);  
  55.           
  56.         if(linear) rotateAni.setInterpolator(new LinearInterpolator()); 
  57.           
  58.         view.startAnimation(rotateAni);  
  59.     }  
  60.       
  61.  
  62.     public static void setScaleAni(View V, float fromScale, float toScale, long ANITIME)  
  63.     {  
  64.         AnimationSet aniSet = new AnimationSet(true);  
  65.        
  66.         ScaleAnimation scaleAni = new ScaleAnimation(fromScale, toScale, fromScale, toScale, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);  
  67.         scaleAni.setDuration(ANITIME);   
  68.         aniSet.addAnimation(scaleAni);  
  69.           
  70.         V.startAnimation(aniSet);       
  71.     }  
  72.       
  73.       
  74.     public static void setLightExpendAni(View V)  
  75.     {  
  76.         AnimationSet aniSet = new AnimationSet(true);  
  77.         final int ANITIME = 1200;  
  78.           
  79.         /  
  80.         ScaleAnimation scaleAni = new ScaleAnimation(0.98f, 1.1f, 0.98f, 1.24f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);  
  81.         scaleAni.setDuration(ANITIME);                
  82.         scaleAni.setRepeatMode(Animation.RESTART);  
  83.         scaleAni.setRepeatCount(Animation.INFINITE); 
  84.         aniSet.addAnimation(scaleAni);    
  85.           
  86.          
  87.         AlphaAnimation alphaAni = new AlphaAnimation(1f, 0.05f);  
  88.         alphaAni.setDuration(ANITIME);                
  89.         alphaAni.setRepeatMode(Animation.RESTART);  
  90.         alphaAni.setRepeatCount(Animation.INFINITE);
  91.         aniSet.addAnimation(alphaAni);   
  92.           
  93.         V.startAnimation(aniSet);         
  94.     }  
  95.       
  96.       
  97.     public static void setLightAni(final View view)  
  98.     {  
  99.         AnimationListener listenser = new AnimationListener()  
  100.         {  
  101.             @Override  
  102.             public void onAnimationEnd(Animation animation)  
  103.             {  
  104.                 view.clearAnimation();  
  105.                 setRotateAni(view, 363996110000, Animation.RESTART, Animation.INFINITE, true);  
  106.             }  
  107.               
  108.             @Override  
  109.             public void onAnimationRepeat(Animation animation)  
  110.             {}  
  111.               
  112.             @Override  
  113.             public void onAnimationStart(Animation animation)  
  114.             {}  
  115.         };  
  116.           
  117.         AnimationSet set = new AnimationSet(true);  
  118.           
  119.           
  120.         AlphaAnimation alphaAni = new AlphaAnimation(0.0f, 1f);  
  121.         alphaAni.setDuration(1000);  
  122.         set.addAnimation(alphaAni);  
  123.           
  124.          
  125.         RotateAnimation rotateAni = new RotateAnimation(036, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);  
  126.         rotateAni.setDuration(1000);  
  127.         set.addAnimation(rotateAni);  
  128.           
  129.        
  130.         ScaleAnimation scaleAni = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);  
  131.         scaleAni.setDuration(1000);  
  132.         scaleAni.setAnimationListener(listenser);  
  133.         set.addAnimation(scaleAni);  
  134.           
  135.         view.startAnimation(set);  
  136.     }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值