亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android中AnimationDrawable使用的簡單實(shí)例

 更新時(shí)間:2013年10月16日 15:53:19   作者:  
這篇文章介紹了Android中AnimationDrawable使用的簡單實(shí)例,有需要的朋友可以參考一下

首先,可以在drawable文件夾下定義一個(gè)xml的文件。如下所示:

復(fù)制代碼 代碼如下:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="true">
    <item android:drawable="@drawable/compass_1" android:duration="70" />
    <item android:drawable="@drawable/compass_2" android:duration="70" />
    <item android:drawable="@drawable/compass_3" android:duration="70" />
    <item android:drawable="@drawable/compass_4" android:duration="70" />
    <item android:drawable="@drawable/compass_5" android:duration="70" />
</animation-list>

根標(biāo)簽為animation-list,其中oneshot代表著是否只展示一遍,設(shè)置為false會(huì)不停的循環(huán)播放動(dòng)畫。其中,每一個(gè)item是一幀,android:duration="400"表示每幀持續(xù)400ms,android:drawable是每幀要顯示的圖片。
接下來,代碼中使用:

復(fù)制代碼 代碼如下:

AnimationDrawable ad = (AnimationDrawable) getResources().getDrawable(R.drawable.bootanimation);

得到AnimationDrawable對(duì)象。再將該對(duì)象設(shè)為當(dāng)前view的backgroud。

復(fù)制代碼 代碼如下:

mView.setBackgroundDrawable(ad);

接著,就可以調(diào)用 ad.start()方法和ad.stop()方法來啟動(dòng)和停止該動(dòng)畫。
注意:必須設(shè)為當(dāng)前view的background,否則start和stop該動(dòng)畫是沒有效果的。

相關(guān)文章

最新評(píng)論