Friday, 3 February 2012

repeatCount and repeatMode of android.view.animation.Animation

  • android:repeatCount: Defines how many times the animation should repeat.
  • android:repeatMode: Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite.


Modify /res/anim/scale.xml in former article "Animation of Scale", add android:repeatCount and android:repeatMode properties; to make animation repeat playing foreward and backward infinitely.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<scale
android:fromXScale="0.0"
android:toXScale="1.0"
android:fromYScale="0.0"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="50%"
android:duration="2000"
android:repeatCount="infinite"
android:repeatMode="reverse"
/>
</set>


No comments:

Post a Comment