小智 5
我就是这样做的.首先拆分GIF并将每个图像添加到drawable文件夹中.然后将新的xml文件添加到drawable(animation.xml)....请参阅下面的示例
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/santa1" android:duration="200" />
<item android:drawable="@drawable/santa2" android:duration="200" />
<item android:drawable="@drawable/santa3" android:duration="200" />
<item android:drawable="@drawable/santa4" android:duration="200" />
<item android:drawable="@drawable/santa5" android:duration="200" />
<item android:drawable="@drawable/santa6" android:duration="200" />
<item android:drawable="@drawable/santa7" android:duration="200" />
</animation-list>
Run Code Online (Sandbox Code Playgroud)
然后当你想要它开始用下面的例子来调用它....
b_1.setBackgroundResource(R.drawable.animation);
AnimationDrawable b1Amin = (AnimationDrawable) b_1.getBackground();
b1Amin.start();
Run Code Online (Sandbox Code Playgroud)