日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

android 创建帧动画,Android 逐帧动画创建实例详解

發(fā)布時間:2023/12/29 Android 17 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 创建帧动画,Android 逐帧动画创建实例详解 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Android 逐幀動畫創(chuàng)建實例詳解

前言:

我們看早期電影的時候,電影通常是一張一張播放,用我們現(xiàn)在專有名詞來說,就是一幀幀來,安卓同樣有這樣動畫效果的編排形式。

那么我們先定義逐幀動畫xml文件

xmlns:android="http://schemas.android.com/apk/res/android"

android:oneshot="true">

android:drawable="@drawable/pic1"

android:duration="200" />

android:drawable="@drawable/pic2"

android:duration="200" />

android:drawable="@drawable/pic3"

android:duration="200" />

android:drawable="@drawable/pic4"

android:duration="200" />

android:drawable="@drawable/pic5"

android:duration="200" />

android:drawable="@drawable/pic6"

android:duration="200" />

android:drawable="@drawable/pic7"

android:duration="200" />

android:drawable="@drawable/pic8"

android:duration="200" />

android:drawable="@drawable/pic8"

android:duration="200" />

main.xml

android:id="@+id/pic"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:layout_marginLeft="98dp"

android:layout_marginTop="69dp"

/>

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"

android:layout_alignParentLeft="true"

android:layout_marginBottom="54dp"

android:layout_marginLeft="98dp"

android:onClick="startMovie"

android:text="開始播放電影" />

Activiy代碼:

public class MyAnimationDemo extends Activity {

private AnimationDrawable draw=null;

private ImageView image;

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_my_animation_demo);

image=(ImageView)super.findViewById(R.id.pic);

}

public void startMovie(View v){

image.setBackgroundResource(R.anim.oldvideo);//第一步,設置圖片資源

draw=(AnimationDrawable)image.getBackground();//取得圖片背景的Drawable

draw.setOneShot(false);//動畫執(zhí)行次數(shù)

draw.start();//開始動畫

}

}

這里我們看到,

第一步,設置圖片背景資源

第二步,設置得到圖片背景的draw

第三步,設置draw參數(shù),并start()

實現(xiàn)效果如下,間隔0.2秒即換圖,實現(xiàn)老電影動畫效果

以上就是Android 逐幀動畫的實例詳解,如有疑問請留言或到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

總結

以上是生活随笔為你收集整理的android 创建帧动画,Android 逐帧动画创建实例详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。