How to create ImageView pulse effect using nine old androids animation

George Taskos picture George Taskos · Jan 8, 2013 · Viewed 28.4k times · Source

I wonder how I should create a pulse effect using nine olad androids framework animation.

To understand better lets say you have an ImageView and want to have a "pulse" effect like make the image little smaller and then back to original size, scaling will be centered.

I use nine olad androids for backward compatibility.

Any other option is welcome.

Thank you.

Answer

Matthias Robbers picture Matthias Robbers · Jan 8, 2013

R.anim.pulse:

<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:duration="1000"
    android:fromXScale="1"
    android:fromYScale="1"
    android:pivotX="50%"
    android:pivotY="50%"
    android:repeatCount="1"
    android:repeatMode="reverse"
    android:toXScale="0.5"
    android:toYScale="0.5" />
ImageView imageView = (ImageView) findViewById(R.id.image);
Animation pulse = AnimationUtils.loadAnimation(this, R.anim.pulse);
imageView.startAnimation(pulse);