Android 动画基础

一、帧动画:

多张图片顺序显示实现动画效果,但是在执行动画是会将所有的图片加载到内存中,图片过多的话可能会导致内存溢出。

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值