帧动画(FrameAnimation)
说明
贞动画按照名字理解就是动画一帧一帧的播放,这个动画相对来说也是很简单。
首先在xml中定义:
<?xml version="1.0" encoding="utf-8"?><!--
根标签为animation-list,其中oneshot代表着是否只展示一遍,设置为false会不停的循环播放动画
根标签下,通过item标签对动画中的每一个图片进行声明
android:duration 表示展示所用的该图片的时间长度
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item
android:drawable="@mipmap/a"
android:duration="300" />
<item
android:drawable="@mipmap/b"
android:duration="300" />
<item
android:drawable="@mipmap/c"
android:duration="300" />
</animation-list>
然后在代码中开始动画就可以了。imageview.setBackgroundResource(R.drawable.iv_bg);
AnimationDrawable animationDrawable = (AnimationDrawable) imageview.getBackground();
animationDrawable.start();
本文介绍了一种简单的帧动画实现方式,通过XML定义一系列图片及其显示时间,并在代码中启动动画。详细讲述了如何创建动画列表资源文件及如何在ImageView中使用AnimationDrawable来播放这些帧动画。
853

被折叠的 条评论
为什么被折叠?



