Contenu connexe
Similaire à Android RotateAnimation 簡介 (20)
Android RotateAnimation 簡介
- 5. new RotateAnimation
Animation animation = new RotateAnimation(
0.0f, 270.0f,
Animation.RELATIVE_TO_SELF, 1.0f,
Animation.RELATIVE_TO_SELF, 1.0f
);
animation.setDuration(2000);
animation.setFillAfter(true);
5
- 6. res/anim/ XML
Animation animation = AnimationUtils.loadAnimation(
this, R.anim.my_animation
);
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<rotate
android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="-1"
android:startOffset="0"/>
</set>
my_animation.xml
6
- 7. XML Attributes
Attribute Name Related Method Description
android:detachWallpaper setDetachWallpaper(boolean) Window wallpaper
android:duration setDuration(long) ( )
android:fillAfter setFillAfter(boolean)
android:fillBefore setFillBefore(boolean) ( AnimationSet)
android:fillEnabled setFillEnabled(boolean) true: fillBefore , false: fillBefore
android:interpolator setInterpolator(Interpolator)
android:repeatCount setRepeatCount(int) (0~N, -1: )
android:repeatMode setRepeatMode(int) (RESTART, REVERSE)
android:startOffset setStartOffset(long) ( )
android:zAdjustment setZAdjustment(int) Z
http://developer.android.com/intl/zh-tw/reference/android/view/animation/RotateAnimation.html#inhattrs
7