Animación de cuadros
La llamada animación de fotogramas consiste en que se reproducen varias imágenes de forma continua.
1. Cree archivos de recursos en dibujables
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<!-- oneshot 是否重复
duration 持续时间 毫秒
drawable 引用图片
-->
<item android:duration="100" android:drawable="@drawable/one"></item>
<item android:duration="100" android:drawable="@drawable/two"></item>
<item android:duration="100" android:drawable="@drawable/three"></item>
<item android:duration="100" android:drawable="@drawable/four"></item>
<item android:duration="100" android:drawable="@drawable/five"></item>
</animation-list>
1, establecer propiedades en ImageView
不是src 是backgroud的属性哦.
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/img"
android:background="@drawable/pic">
</ImageView>
3, define las propiedades de la animación
private AnimationDrawable animationDrawable;
4. Cómo usar
//帧动画
animationDrawable = (AnimationDrawable) img.getBackground();
//启动
animationDrawable.start();
//停止
animationDrawable.stop();