1
我試圖讓我的Android應用程序的AnimationDrawable重複。 我配置了android:oneshot爲false。 (嘗試都與Java與XML) 儘管如此,每當播放動畫時,一旦完成,它可以追溯到第一幀,並停止Android AnimationDrawable開始,並且完成時掛起第一幀
這是我的XML文件
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/network_scanning" android:oneshot="false">
<item android:drawable="@drawable/network_wireless_0" android:duration="300" />
<item android:drawable="@drawable/network_wireless_1" android:duration="300" />
<item android:drawable="@drawable/network_wireless_2" android:duration="300" />
<item android:drawable="@drawable/network_wireless_3" android:duration="300" />
<item android:drawable="@drawable/network_wireless_4" android:duration="300" />
</animation-list>
和這是啓動動畫代碼:
@Override
public void onWindowFocusChanged(boolean hasFocus)
{
super.onWindowFocusChanged(hasFocus);
LinearLayout network = (LinearLayout) findViewById(R.id.wifi_anim);
AnimationDrawable anim = (AnimationDrawable) network.getBackground();
if (hasFocus)
{
anim.setOneShot(false);
anim.setCallback(network);
anim.setVisible(true, true);
anim.start();
}
}