ImageView startGame = (ImageView) findViewById(R.id.egg);
startGame.setBackgroundResource(R.drawable.animation1);
animationDrawable = (AnimationDrawable) startGame.getBackground();
animationDrawable.start();
xml文件:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/background1"
android:duration="500">
</item>
<item
android:drawable="@drawable/background2"
android:duration="500">
</item>
<item
android:drawable="@drawable/background3"
android:duration="500">
</item>
</animation-list>