学习资源:https://developer.android.google.cn/guide/topics/graphics/drawable-animation#java
logo.xml
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<!--oneshot:是否设置为一次播放;duration:持续时间-->
<item android:drawable="@drawable/logo1" android:duration="200" />
<item android:drawable="@drawable/logo2" android:duration="200" />
<item android:drawable="@drawable/logo3" android:duration="200" />
</animation-list>
public class MainActivity extends AppCompatActivity {
private ImageView iV;
private AnimationDrawable aD;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
iV= findViewById(R.id.iV);
iV.setBackgroundResource(R.drawable.logo);
aD= (AnimationDrawable) iV.getBackground();
//开启动画
aD.start();
}
}