一、帧动画:
多张图片顺序显示实现动画效果,但是在执行动画是会将所有的图片加载到内存中,图片过多的话可能会导致内存溢出。
1、在drawable下新建一个资源文件frame_animator
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<!-- oneshot是否只执行一次,true只执行一次-->
<item android:drawable="@mipmap/img1" android:duration="300"/>
<item android:drawable="@mipmap/img2" android:duration="300"/>
<item android:drawable="@mipmap/img3" android:duration="300"/>
<item android:drawable="@mipmap/img4" android:duration="300"/>
<item android:drawable="@mipmap/img5" android:duration="300"/>
</animation-list>
2、在代码中开启动画
mTweenImg.setImageResource(R.drawable.frame_animator);
anima = (AnimationDrawable) mTweenImg.getDrawable();
anima.start();
//anima.stop()
二、补间动画
补间动画有四种:位移、缩放、旋转、淡入淡出。补间动画不改变图片的具体位置,不改变图片的具体属性
三、属性动画
补间动画的所有效果属性动画都可以实现,而且属性动画可以改变View的具体位置。
代码地址:https://github.com/kunofhan/EasyAnimatou