Drawable animation可以加载Drawable资源实现帧动画。AnimationDrawable是实现Drawable animations的基本类。
这里用AnimationDrawable 简单模拟动态图的实现。
fragment_main 布局文件 ---- 只需要放一个 ImageView即可
1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.com/tools" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 tools:context="com.yztc.frameanimation.MainActivity" > 6 7 <ImageView 8 android:id="@+id/iv_frame" 9 android:layout_width="match_parent" 10 android:layout_height="200dp" 11 android:background="@drawable/girl_and_boy" /> 12 13 </RelativeLayout>