Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Android 图片翻转动画

Android 图片翻转动画font.xml
  • <?xml version="1.0" encoding="utf-8"?> 
  1. <set xmlns:android="http://schemas.android.com/apk/res/android"   
  2.      android:interpolator="@android:anim/accelerate_interpolator">   
  3.      <scale   
  4.         android:fromXScale="0.0"   
  5.         android:toXScale="1.0"   
  6.         android:fromYScale="1.0"   
  7.         android:toYScale="1.0"   
  8.         android:pivotX="50%"   
  9.         android:pivotY="50%"   
  10.         android:duration="150"/>   
  11. </set>
back.xml
  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> 
使用:
  1. Animation aniback = AnimationUtils.loadAnimation(getContext(), R.anim.back); 
  2. aniback.setAnimationListener(new AnimationListener() 
  3.     @Override 
  4.     public void onAnimationStart(Animation animation) 
  5.     { 
  6.     } 
  7.  
  8.     @Override 
  9.     public void onAnimationRepeat(Animation animation) 
  10.     { 
  11.     } 
  12.  
  13.     @Override 
  14.     public void onAnimationEnd(Animation animation) 
  15.     { 
  16.         if (isCNPic) 
  17.         { 
  18.             ivPic.setImageResource(R.drawable.system_tip1); 
  19.             isCNPic = false
  20.         } 
  21.         else 
  22.         { 
  23.             ivPic.setImageResource(R.drawable.system_tip0); 
  24.             isCNPic = true
  25.         } 
  26.         ivPic.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.font)); 
  27.     } 
  28. }); 
  29. ivPic.startAnimation(aniback); 
更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11