Android帧动画Drawable Animation

来源:互联网 发布:java命令行执行junit 编辑:程序博客网 时间:2024/06/05 13:33

查看谷歌文档:
1、创建一个Android xml文件

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="true">     <item android:drawable="@drawable/rocket_thrust1" android:duration="200" />     <item android:drawable="@drawable/rocket_thrust2" android:duration="200" />     <item android:drawable="@drawable/rocket_thrust3" android:duration="200" /> </animation-list> 

2.使用

        view = View.inflate(this, R.layout.rocket, null);// 初始化火箭布局        // 初始化火箭帧动画        ImageView ivRocket = (ImageView) view.findViewById(R.id.iv_rocket);             ivRocket.setBackgroundResource(R.drawable.anim_rocket);        AnimationDrawable anim = (AnimationDrawable) ivRocket.getBackground();        anim.start();
0 0
原创粉丝点击