Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Android RotateAnimation 簡介

Sample code: https://github.com/ccc-larc/TryAndroidRotateAnimation

  • Be the first to comment

Android RotateAnimation 簡介

  1. 1. Android RotateAnimation
  2. 2. http://developer.android.com/intl/zh-tw/reference/android/view/animation/RotateAnimation.html 2
  3. 3. RotateAnimation new RotateAnimation res/anim/ XML 3
  4. 4. new RotateAnimation 4
  5. 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. 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. 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
  8. 8. Sample Code https://github.com/ccc-larc/TryAndroidRotateAnimation 8

×