歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux編程 >> 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. { 
  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); 

更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11

Copyright © Linux教程網 All Rights Reserved