Android动画详解(一) 逐帧动画

1、 逐帧动画说明

从字面上理解就是一帧挨着一帧的播放多张图片,就像放电影一样。

2、实现方式

2.1 xml drawable资源配置

2.1.1 将准备好的多张图片放入res/drawable目录下

准备图片资源

2.1.2 在res/drawable创建animlist.xml文件

说明:
android:oneshot=”false” 是否播放一次,false循环播放 true播放一次
android:duration=”200” 播放时间间隔

<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
    <item
        android:drawable="@drawable/page_score_pic_0"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_1"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_2"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_3"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_4"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_5"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_6"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_7"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_8"
        android:duration="200">
    </item>
    <item
        android:drawable="@drawable/page_score_pic_9"
        android:duration="200">
    </item>
</animation-list>
2.1.3 通过ImageView作为动画播放的载体
  <ImageView
        android:id="@+id/anim_iv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/animlist"/>
2.1.4 实现动画播放的代码
anim_iv = (ImageView) findViewById(R.id.anim_iv);
AnimationDrawable animationDrawable = (AnimationDrawable) anim_iv.getDrawable();
animationDrawable.start();

3、效果

这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值