1. 帧动画
将多个图片放在一起,,连续播放形成的动画,类似于GIF
2. 实现原理
3. XML文件
在res/anim文件夹中创建一个anim_logo.xml的文件, 具体内容如下:
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="" android:oneshot="false"><item android:drawable="@drawable/ic_logo1" android:duration="500" /><item android:drawable="@drawable/ic_logo2" android:duration="500" /><item android:drawable="@drawable/ic_logo3" android:duration="500" /><item android:drawable="@drawable/ic_logo4" android:duration="500" /></animation-list>
每个item对应一个图片, android:duration可以设定该图片的显示时长。
android:oneshot
false : 循环播放
true: 播放一次
4. 调用动画
<ImageViewandroid:id="@+id/iv_click_image"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/txt_status"android:paddingLeft="15dp"android:layout_marginTop="15dp"android:layout_centerHorizontal="true"android:background="@anim/anim_logo"/>5. 开始动画
AnimationDrawable anim = (AnimationDrawable) mLogoImg.getBackground();anim.start();6. 停止动画
AnimationDrawable anim = (AnimationDrawable) mLogoImg.getBackground();anim.stop();
转动心中的期待,血在澎湃,吃苦流汗算什么。