主java
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class AndroidAnimation extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.animation1);
ImageView myAnimation = (ImageView)findViewById(R.id.myanimation1);
final AnimationDrawable myAnimationDrawable
= (AnimationDrawable)myAnimation.getDrawable();
myAnimation.post(
new Runnable(){
public void run() {
myAnimationDrawable.start();
}
});
}
}
xml 文件
<?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/default_01_0001"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0002"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0003"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0004"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0005"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0006"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0007"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0008"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0009"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0010"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0011"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0012"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0013"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0014"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0015"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0016"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0017"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0018"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0019"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0020"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0021"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0022"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0023"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0024"
android:duration="80"/>
<item
android:drawable="@drawable/default_01_0025"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0001"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0002"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0003"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0004"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0005"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0006"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0007"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0008"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0009"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0010"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0011"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0012"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0013"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0014"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0015"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0016"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0017"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0018"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0019"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0020"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0021"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0022"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0023"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0024"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0025"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0026"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0027"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0028"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0029"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0030"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0031"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0032"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0033"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0034"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0035"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0036"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0037"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0038"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0039"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0040"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0041"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0042"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0043"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0044"
android:duration="80"/>
<item
android:drawable="@drawable/default_03_0045"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0001"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0002"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0003"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0004"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0005"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0006"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0007"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0008"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0009"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0010"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0011"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0012"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0013"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0014"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0015"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0016"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0017"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0018"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0019"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0020"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0021"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0022"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0023"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0024"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0025"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0026"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0027"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0028"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0029"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0030"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0031"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0032"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0033"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0034"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0035"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0036"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0037"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0038"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0039"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0040"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0041"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0042"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0043"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0044"
android:duration="80"/>
<item
android:drawable="@drawable/default_02_0045"
android:duration="80"/>
</animation-list>
我使用 AnimationDrawable 制作了逐帧动画。当图像低于 20pic 时,应用程序工作正常,但在我在应用程序中添加更多图像后,出现崩溃。
任何可以分享一些教程如何制作动画可以加载更多图像?我买了两本书也用同样的方法来创建逐帧动画。有什么好书推荐吗?
谢谢