文章出處

通過播放一張一張圖片來實現一段動畫

首先配置anim.xml:

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

 

然后用一個ImageView顯示

1 <ImageView
2         android:id="@+id/iv"
3         android:layout_centerInParent="true"
4         android:onClick="click3"
5         android:clickable="true"
6         android:layout_width="200dp"
7         android:layout_height="200dp" />

再。。。。

1 public void click3(View v){
2         ImageView iv = (ImageView)findViewById(R.id.iv);
3         iv.setBackgroundResource(R.drawable.anim);
4         AnimationDrawable ad = (AnimationDrawable)iv.getBackground();
5         ad.start();
6     }

 

就是這么簡單。。。。

 


文章列表




Avast logo

Avast 防毒軟體已檢查此封電子郵件的病毒。
www.avast.com


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()