我正在尝试为一些 png 设置动画,然后循环播放动画。这是我的代码:
wave.setBackgroundResource(R.drawable.wave_animation);
frameAnimation = (AnimationDrawable)wave.getBackground();
frameAnimation.setCallback(wave);
frameAnimation.setVisible(true, true);
frameAnimation.start();
这里是带有png的xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">
<item android:drawable="@drawable/wave_01" android:duration="200" />
<item android:drawable="@drawable/wave_02" android:duration="200" />
<item android:drawable="@drawable/wave_03" android:duration="200" />
<item android:drawable="@drawable/wave_04" android:duration="200" />
</animation-list>
我还添加了 android:oneshot=false 但不起作用。