安卓动画之Frame动画

来源:互联网 发布:Linux进入根目录的命令 编辑:程序博客网 时间:2024/06/09 18:31
帧动画是按顺序播放一组预先定义好的图片,不同于View动画,系统提供了另外一个类AnimationDrawable来使用帧动画
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/share_eject1" android:duration="500"/>
<item android:drawable="@drawable/share_eject2" android:duration="500"/>
<item android:drawable="@drawable/share_eject3" android:duration="500"/>
</animation-list>

frame = (Button) findViewById(R.id.frame);
frame.setBackgroundResource(R.drawable.frame_animation);
AnimationDrawable drawable = (AnimationDrawable) frame.getBackground();
drawable.start();

2 0