Android动画之ScaleAnimation

1.缩放动画ScaleAnimation

scale_animation.xml

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fillAfter="true"    android:interpolator="@android:anim/accelerate_decelerate_interpolator">

    <scale
        android:fromXScale="1"
        android:toXScale="2"
        android:fromYScale="1"
        android:toYScale="2"
        android:pivotX="50%"
        android:pivotY="50%"
        android:repeatCount="0"/>

</set>

android:fromXScale=”1”——x轴从本身大小开始缩放
android:toXScale=”2”——x轴缩放到自己的一倍
android:fromYScale=”1”——y轴从本身大小开始缩放
android:toYScale=”2”——y轴缩放到自己的一倍
android:pivotX=”50%”——x轴从中心点缩放
android:pivotY=”50%”——y轴从中心点缩放
android:repeatCount=”0”——不重复

2.代码中使用动画

//利用资源文件加载动画
//mAnimation = AnimationUtils.loadAnimation(MainActivity.this,R.anim.rotate_animation);
//mImg.startAnimation(mAnimation);

//在代码中使用动画
RotateAnimation animation = new RotateAnimation(0, 360,
RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
//不停顿
animation.setInterpolator(new LinearInterpolator());
//重复次数
animation.setRepeatCount(0);
animation.setFillAfter(true);
animation.setDuration(2000);
//开启动画
mImg.startAnimation(animation);

3.运行截图

这里写图片描述

4.源码下载

下载地址:https://github.com/zeke123/Animation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值