In Android, I’ve created an animated button by referencing the below XML in the button_pressed.xml:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="@drawable/btn_on_1" android:duration="30" />
<item android:drawable="@drawable/btn_on_2" android:duration="30" />
<item android:drawable="@drawable/btn_on_3" android:duration="30" />
<item android:drawable="@drawable/btn_on_4" android:duration="30" />
<item android:drawable="@drawable/btn_on_5" android:duration="30" />
</animation-list>
It works fine, but if you hold the button down (keep it pressed) the animation loops. Is there an XML call I can put in the above XML to keep the animation from looping? To make it run through the animation only once?
You can simply call the animation on button click(using onClickListener()) instead.. this will start your animation only if the user performs a full click action on the button (press + release).
EDIT: