幀動畫

private ImageView iv;


iv = (ImageView) findViewById(R.id.iv);
iv.setBackgroundResource(R.drawable.anim);
AnimationDrawable anim = (AnimationDrawable) iv.getBackground();
anim.start();



anim

<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="true">

    <item
        android:drawable="@drawable/pic_1"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_2"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_3"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_4"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_5"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_6"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_7"
        android:duration="500"/>
    <item
        android:drawable="@drawable/pic_8"
        android:duration="100"/>
    <item
        android:drawable="@drawable/pic_9"
        android:duration="100"/>

</animation-list>

是否循環播放

android:oneshot="true"  只播放一次

false  循環播放



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章