Android动画 之 Tween Animation(ScaleAnimation 大小渐变)

本文介绍了如何在Android中使用ScaleAnimation实现视图缩放效果。包括创建XML配置文件的方法及动画属性设置详解。
public class

ScaleAnimation

extends Animation

java.lang.Object

   ↳

android.view.animation.Animation

 

   ↳

android.view.animation.ScaleAnimation

 

一、创建xml配置文件

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
	android:fromXScale="0.0"
	android:toXScale="1.0"
	android:fromYScale="0.0"
	android:toYScale="1.0"
	android:duration="500"
	android:fillAfter="true"
	android:repeatCount="20"
>
</scale>


二、开启动画(Tween Animation开启基本一致)

iv_show = (ImageView) findViewById(R.id.iv_show);
final ScaleAnimation aa = (ScaleAnimation) AnimationUtils
	.loadAnimation(this, R.anim.anim_scale);
iv_show.startAnimation(aa);


附:动画属性设置

From class android.view.animation.Animation

Attribute Name Related Method Description
android:detachWallpapersetDetachWallpaper(boolean)Special option for window animations: if this window is on top of a wallpaper, don't animate the wallpaper with it. 
android:durationsetDuration(long)Amount of time (in milliseconds) for the animation to run. 
android:fillAftersetFillAfter(boolean)When set to true, the animation transformation is applied after the animation is over. 
android:fillBeforesetFillBefore(boolean)When set to true, the animation transformation is applied before the animation has started. 
android:fillEnabledsetFillEnabled(boolean)When set to true, fillAfter is taken into account. 
android:interpolatorsetInterpolator(Interpolator)Defines the interpolator used to smooth the animation movement in time. 
android:repeatCountsetRepeatCount(int)Defines how many times the animation should repeat. 
android:repeatModesetRepeatMode(int)Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite. 
android:startOffsetsetStartOffset(long)Delay in milliseconds before the animation runs, once start time is reached. 
android:zAdjustmentsetZAdjustment(int)Allows for an adjustment of the Z ordering of the content being animated for the duration of the animation. 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值