android 动画详解之帧动画

来源:互联网 发布:万能电视遥控器软件 编辑:程序博客网 时间:2024/06/05 01:12

android 动画分为视图动画、帧动画、属性动画

其中帧动画是顺序播放一组图片,android提供AnimationDrawable来使用帧动画,使用帧动画,首先需要在drawable文件夹中定义一个AnimationDrawable。


<?xmlversion="1.0"encoding="utf-8"?>

<animation-listxmlns:android="http://schemas.android.com/apk/res/android"android:oneshot="false">

<itemandroid:drawable="@drawable/spring"android:duration="500"/>

    <itemandroid:drawable="@drawable/summar"android:duration="500"/>

    <itemandroid:drawable="@drawable/dong"android:duration="500"/>


</animation-list>


其中 android:oneshot="false" 属性设置为false表示图片循环播放, duration属性表现每一张图片播放的时间。


下面介绍在activity中如何调用animation图片。



imageView.setBackgroundResource(R.drawable.myanimation);

AnimationDrawable drawable=(AnimationDrawable)imageView.getBackground();

drawable.start();






原创粉丝点击