我想在android中執行逐幀動畫。對於這個任務,我創建了一個名爲「anim.xml」像這樣的XML文件:問題關於逐幀動畫的具體android問題
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/square0" android:duration="100" />
<item android:drawable="@drawable/square1" android:duration="100" />
<item android:drawable="@drawable/square2" android:duration="100" />
<item android:drawable="@drawable/square3" android:duration="100" />
<item android:drawable="@drawable/square4" android:duration="100" />
<item android:drawable="@drawable/square5" android:duration="100" />
</animation-list>
然後,在我所定義的幀結構,我試圖將其設置爲背景,並啓動它在的onCreate這樣的:
FrameLayout imgView = (FrameLayout)findViewById(R.id.frameLayout1);
imgView.setBackgroundResource(R.drawable.anim);
AnimationDrawable anim = (AnimationDrawable) imgView.getBackground();
anim.start();
我所經歷的僅僅是第一幀,但我要做的是將一個正方形的動畫放在循環中。你對我做錯了什麼有什麼意見嗎?
乾杯。
有趣,但它的作品是這樣^^ – Pumpkin