4

I have a circular image button that I would like to animate in the following manner, zoom the button to 1.5 times its size quickly and then zoom it out with a bouncy effect.

For this I am trying to create an animation set with 2 scale animations in it and then calling it with Animation anim = AnimationUtils.loadAnimation(context, R.anim.button); view.startAnimation(anim); but it plays only once even if I set the repeatDuration="infinte" in the set.

How can I play multiple animations on a view in sequence infinitely? Any help appreciated.

The button.xml anim is,

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:ordering="sequentially"
    android:repeatDuration="infinite"
    android:shareInterpolator="false">

    <scale
        android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="1.0"
        android:toXScale="1.1"
        android:fromYScale="1.0"
        android:toYScale="1.0"
        android:duration="2000"
        android:pivotX="50%"
        android:pivotY="50%" />

    <scale
        android:interpolator="@android:anim/bounce_interpolator"
        android:fromXScale="1.1"
        android:fromYScale="1.1"
        android:toXScale="1.0"
        android:toYScale="1.0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:duration="2000"
        android:startOffset="2000" />

</set>
Bootstrapper
  • 1,089
  • 3
  • 14
  • 33

1 Answers1

3

try this, put android:interpolator in set tag.

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/bounce_interpolator" >
    <scale
        android:duration="600"
        android:fromXScale="1"
        android:fromYScale="0.5"
        android:pivotX="50%"
        android:pivotY="0%"
        android:toXScale="1.0"
        android:toYScale="1.0" />

    <alpha
        android:duration="600"
        android:fromAlpha="0.0"
        android:toAlpha="1.0" />
</set>
Gary Chen
  • 248
  • 2
  • 14
Divyang Panchal
  • 1,889
  • 1
  • 19
  • 27