Android 图片翻转动画

来源:互联网 发布:能看cctv5的网络电视 编辑:程序博客网 时间:2024/05/01 02:28
font.xml

[html] view plaincopyprint?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"   
  3.      android:interpolator="@android:anim/accelerate_interpolator">   
  4.      <scale   
  5.         android:fromXScale="0.0"   
  6.         android:toXScale="1.0"   
  7.         android:fromYScale="1.0"   
  8.         android:toYScale="1.0"   
  9.         android:pivotX="50%"   
  10.         android:pivotY="50%"   
  11.         android:duration="150"/>   
  12. </set>  

back.xml

[html] view plaincopyprint?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set xmlns:android="http://schemas.android.com/apk/res/android"   
  3.      android:interpolator="@android:anim/accelerate_interpolator">   
  4.      <scale   
  5.         android:fromXScale="1.0"   
  6.         android:toXScale="0.0"   
  7.         android:fromYScale="1.0"   
  8.         android:toYScale="1.0"   
  9.         android:pivotX="50%"   
  10.         android:pivotY="50%"   
  11.         android:duration="150"/>   
  12. </set>  

使用:

[java] view plaincopyprint?
  1. Animation aniback = AnimationUtils.loadAnimation(getContext(), R.anim.back);  
  2. aniback.setAnimationListener(new AnimationListener()  
  3. {  
  4.     @Override  
  5.     public void onAnimationStart(Animation animation)  
  6.     {  
  7.     }  
  8.   
  9.     @Override  
  10.     public void onAnimationRepeat(Animation animation)  
  11.     {  
  12.     }  
  13.   
  14.     @Override  
  15.     public void onAnimationEnd(Animation animation)  
  16.     {  
  17.         if (isCNPic)  
  18.         {  
  19.             ivPic.setImageResource(R.drawable.system_tip1);  
  20.             isCNPic = false;  
  21.         }  
  22.         else  
  23.         {  
  24.             ivPic.setImageResource(R.drawable.system_tip0);  
  25.             isCNPic = true;  
  26.         }  
  27.         ivPic.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.font));  
  28.     }  
  29. });  
  30. ivPic.startAnimation(aniback);  
原创粉丝点击