I did the following:
Create file AnimationClick.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item android:drawable="@drawable/ButtonState1" android:duration="250"/>
<item android:drawable="@drawable/ButtonState2" android:duration="250"/>
<item android:drawable="@drawable/ButtonState3" android:duration="250"/>
<item android:drawable="@drawable/ButtonState4" android:duration="250"/>
</animation-list>
And create file ItemImage.axml:
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/LeSommet.ZooSnap.UI.Android"
android:layout_width="80dp"
android:layout_height="80dp"
android:padding="5dp"
android:layout_gravity="center"
android:src="@drawable/AnimationClick"
/>
To run this animation should do the following:
ImageView image = (ImageView)FindViewById(Resource.Id.imageAnimation);
animation = (AnimationDrawable)image.Drawable;
animation.Start();
imageAnimation - My ImageView.
But I use a GridView in which 20 ItemImage. How to start an animation when pressed on one of the ImageView?