原文地址:Android view动画之缩放动画_南国樗里疾的博客-****博客_android view 缩放动画
方法一
用 AnimationUtils 和 xml 的方式,加载指定的缩放动画。
Animation scaleAnimation = (mContext, .scale_animation);
(true);
(scaleAnimation);
scale_animation.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:andro >
<!--
android:fromXScale
Float. 水平方向缩放比例的初始值,其中1.0是没有任何变化。
android:toXScale
Float. 水平方向缩放比例的结束值,其中1.0是没有任何变化。
android:fromYScale
Float. 竖直方向缩放比例的初始值,其中1.0是没有任何变化。
android:toYScale
Float. 竖直方向缩放比例的结束值,其中1.0是没有任何变化。
android:pivotX
Float. 缩放中心点的x坐标
android:pivotY
Float. 缩放中心点的y坐标
-->
<scale
android:duration="5000"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="0.5"
android:toYScale="0.5" />
</set>
这个效果是缩小。
方法二
直接代码设置,效果是放大。
ScaleAnimation scaleAnim = new ScaleAnimation(1, 1.5f, 1,1.5f);
(true);
(scaleAnim);
方法三
属性动画实现,
//利用AnimatorSet和ObjectAnimator实现缩放动画
final AnimatorSet animatorSet = new AnimatorSet();
(() / 2);
(() / 2);
(
(mImageView, "scaleX", 1, 1.5f).setDuration(5000),
(mImageView, "scaleY", 1, 1.5f).setDuration(5000));
();