使ImageView中的图片可以动起来
1.在drawable-mdpi文件夹下加入图片,并加入一个xml文件,文件如下
- <?xml version="1.0" encoding="utf-8"?>
- <animation-list xmlns:android="http://schemas.android.com/apk/res/android" >
- <item android:drawable="@drawable/a" android:duration="500"/>
- <item android:drawable="@drawable/b" android:duration="500"/>
- <item android:drawable="@drawable/c" android:duration="500"/>
- <item android:drawable="@drawable/d" android:duration="500"/>
- </animation-list>
2.代码如下
- iv.setBackgroundResource(R.drawable.anim);
- AnimationDrawable an=(AnimationDrawable)iv.getBackground();
- an.start();