Android 圖片翻轉動畫
font.xml
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
- <scale
- android:fromXScale="0.0"
- android:toXScale="1.0"
- android:fromYScale="1.0"
- android:toYScale="1.0"
- android:pivotX="50%"
- android:pivotY="50%"
- android:duration="150"/>
- </set>
back.xml
- <?xml version="1.0" encoding="utf-8"?>
- <set xmlns:android="http://schemas.android.com/apk/res/android"
- android:interpolator="@android:anim/accelerate_interpolator">
- <scale
- android:fromXScale="1.0"
- android:toXScale="0.0"
- android:fromYScale="1.0"
- android:toYScale="1.0"
- android:pivotX="50%"
- android:pivotY="50%"
- android:duration="150"/>
- </set>
使用:
- Animation aniback = AnimationUtils.loadAnimation(getContext(), R.anim.back);
- aniback.setAnimationListener(new AnimationListener()
- {
- @Override
- public void onAnimationStart(Animation animation)
- {
- }
-
- @Override
- public void onAnimationRepeat(Animation animation)
- {
- }
-
- @Override
- public void onAnimationEnd(Animation animation)
- {
- if (isCNPic)
- {
- ivPic.setImageResource(R.drawable.system_tip1);
- isCNPic = false;
- }
- else
- {
- ivPic.setImageResource(R.drawable.system_tip0);
- isCNPic = true;
- }
- ivPic.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.font));
- }
- });
- ivPic.startAnimation(aniback);
更多Android相關信息見Android 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=11