Android动画之图片动画(四)

来源:互联网 发布:易语言qq抢红包源码 编辑:程序博客网 时间:2024/06/09 22:40

现在使ImageView中的图片可以动起来

1.在drawable-mdpi文件夹下加入图片,并加入一个xml文件,文件如下

[html] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <animation-list xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.   <item android:drawable="@drawable/a" android:duration="500"/>   
  4.   <item android:drawable="@drawable/b" android:duration="500"/>   
  5.   <item android:drawable="@drawable/c" android:duration="500"/>   
  6.   <item android:drawable="@drawable/d" android:duration="500"/>   
  7.   
  8. </animation-list>  


2.代码如下

[java] view plaincopy
  1. iv.setBackgroundResource(R.drawable.anim);  
  2.             AnimationDrawable an=(AnimationDrawable)iv.getBackground();  
  3.             an.start();  
原创粉丝点击