歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android 圖片翻轉動畫

Android 圖片翻轉動畫

日期:2017/3/1 10:00:52   编辑:Linux編程

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. @Override
  9. public void onAnimationRepeat(Animation animation)
  10. {
  11. }
  12. @Override
  13. public void onAnimationEnd(Animation animation)
  14. {
  15. if (isCNPic)
  16. {
  17. ivPic.setImageResource(R.drawable.system_tip1);
  18. isCNPic = false;
  19. }
  20. else
  21. {
  22. ivPic.setImageResource(R.drawable.system_tip0);
  23. isCNPic = true;
  24. }
  25. ivPic.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.font));
  26. }
  27. });
  28. ivPic.startAnimation(aniback);

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

Copyright © Linux教程網 All Rights Reserved