现在的位置: 首页 > 综合 > 正文

Android动画之图片动画(四)

2018年04月19日 ⁄ 综合 ⁄ 共 649字 ⁄ 字号 评论关闭

使ImageView中的图片可以动起来

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

[html] view
plain
copy

  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
plain
copy

  1. iv.setBackgroundResource(R.drawable.anim);  
  2.             AnimationDrawable an=(AnimationDrawable)iv.getBackground();  
  3.             an.start();  

抱歉!评论已关闭.