android中动画学习

动画的类在AndroidSDK/sources/android-17/android/view/animation文件夹中。。。

如下图:

经过整理,可分为3类:

1. Interpolator部分

Interpolator是基类

Class/InterfaceDescription
AccelerateDecelerateInterpolatorAn interpolator whose rate of change starts and ends slowly but accelerates through the middle.
AccelerateInterpolatorAn interpolator whose rate of change starts out slowly and then accelerates.
AnticipateInterpolatorAn interpolator whose change starts backward then flings forward.
AnticipateOvershootInterpolatorAn interpolator whose change starts backward, flings forward and overshoots the target value, then finally goes back to the final value.
BounceInterpolatorAn interpolator whose change bounces at the end.
CycleInterpolatorAn interpolator whose animation repeats for a specified number of cycles.
DecelerateInterpolatorAn interpolator whose rate of change starts out quickly and and then decelerates.
LinearInterpolatorAn interpolator whose rate of change is constant.
OvershootInterpolatorAn interpolator whose change flings forward and overshoots the last value then comes back.
TimeInterpolatorAn interface that allows you to implement your own interpolator.

是Interpolator的派生类。这些都被统称为Property Animation。


2. Animation部分

Animation是基类。。。

AlphaAnimation

RotateAnimation

ScaleAnimation

TranslateAnimation为Animation的派生类。这些是Animation部分。


3. 杂项

AnimationSet, AnimationUtils, GridLayoutAnimationController, LayoutAnimationController

这些后续分析。。


//

// Add Time: 2013/6/28

有关自定义动画的部分

上次还没有分析TimeInterpolator,现在来分析一下。

interpolator 的含义为:【计】 校对机, 分类机, 插补器, 内插器, 插入器

上次说到那些Interpolator相关的类都是派生与Interpolator的,

很重要的一点Interpolator的父类为TimeInterpolator。

因此我们新建一个类,其父类为TimeInterpolator就可以自定义动画了。

下面是重载的是模拟BounceInterpolator的动画实现。。

mObjectAnim.setInterpolator(new TimeInterpolator() {
				    private float bounce(float t) {
				        return t * t * 8.0f;
				    }
					@Override
					public float getInterpolation(float t) {
						// TODO Auto-generated method stub
						// _b(t) = t * t * 8
						// bs(t) = _b(t) for t < 0.3535
						// bs(t) = _b(t - 0.54719) + 0.7 for t < 0.7408
						// bs(t) = _b(t - 0.8526) + 0.9 for t < 0.9644
						// bs(t) = _b(t - 1.0435) + 0.95 for t <= 1.0
						// b(t) = bs(t * 1.1226)
						t *= 1.1226f;
						if (t < 0.3535f) return bounce(t);
						else if (t < 0.7408f) return bounce(t - 0.54719f) + 0.7f;
						else if (t < 0.9644f) return bounce(t - 0.8526f) + 0.9f;
						else return bounce(t - 1.0435f) + 0.95f;
					}

				});
你可以更改算法来实现个性的动画。








  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值