android中使用frameAnimation幀動畫方法

frameAnimation幀動畫

   注意:outofmemory(7.8張圖片)

   優化方法:把動態和靜態部分分開,靜態做背景,動態做動畫

   使用步驟:

       1.美工做好單幀動畫

       2.新建xml,新建resouse type爲drawble,根元素爲animation_list

   <item android:drawable="@drawable/angela_blink_0001" android:duration="100"/>

    定義好圖片和間隔時間

    android:oneshot="true" 單次循環

<?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/angela_blink_0001" android:duration="100"/>
    <item android:drawable="@drawable/angela_blink_0002" android:duration="100"/>
    <item android:drawable="@drawable/angela_blink_0003" android:duration="100"/>
    <item android:drawable="@drawable/angela_blink_0004" android:duration="100"/>
    <item android:drawable="@drawable/angela_blink_0005" android:duration="100"/>
    <item android:drawable="@drawable/angela_blink_0006" android:duration="100"/>
                   
</animation-list>


       3.代碼中得到:

ImageView p_w_picpathView = (ImageView) findViewById(R.id.p_w_picpathView1);
    final AnimationDrawable animationDrawable = (AnimationDrawable)     p_w_picpathView.getDrawable()

 

    播放動畫.start();

   停止動畫.stop();



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