If your image is a .gif you can not load it simply by defining the background as the background. In fact, the gif in ImageButton
are not supported.
As an option, separate your images in frames and add the images inside the folder /drawable
, for example animation.xml
:
<animation-list android:oneshot="false" xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/frame1" android:duration="2" />
<item android:drawable="@drawable/frame2" android:duration="2" />
<item android:drawable="@drawable/frame3" android:duration="2" />
<item android:drawable="@drawable/frame4" android:duration="2" />
<item android:drawable="@drawable/frame5" android:duration="2" />
<item android:drawable="@drawable/frame6" android:duration="2" />
<item android:drawable="@drawable/frame7" android:duration="2" />
<item android:drawable="@drawable/frame8" android:duration="2" />
<item android:drawable="@drawable/frame9" android:duration="2" />
<item android:drawable="@drawable/frame10" android:duration="2" />
</animation-list>
and in this way load the animation to your ImageButton
:
<ImageButton
android:id="@+id/imageButton"
...
...
android:src="@drawable/animation"/>