Home
JavaEE
Java GUI
Framework
DHtml
Android
插画
教程下载

ATOM 2.0   RSS 2.0
Add to iGoogle Add to Live.com
  • 今天终于收到金山快盘的邀请码
  • 利用最短ie判断在不同浏览器上播放背景音乐
  • 对插画方面的一点感受与回忆
  • 网上看到的两个死里逃生的图片,记录一下
  • 今天开通了糖果社区,附几个激活码
  • 终于可以实现我的多个微博实时同步了
  • 备案和现场拍照就是对站长们的瞎折腾
  • 对Android在互联网应用开发上的纠结
  • 收藏夹中的书签都没了,决定写一个自已的书签管理器
  • 测试自已整理的本机的webapps客户端发送博文能否成功。
  • 今天开通了糖果社区,附几个激活码
  • 终于可以实现我的多个微博实时同步了
  • 备案和现场拍照就是对站长们的瞎折腾
  • 昨天借用飞姐的佳作做的一个浪漫爱情网页
  • 有几个腾讯微博的邀请码(实时更新)
  • BB的网站移到了GAE-JAVA上了
  • 一个基于GAE Python Web.py和JQuery的留言本程序
  • 类许愿墙的一个告白网站和一个电子书网站
  • Android中用Bitmap获取图片中某个区域的图象
  • 对暴力破解带密码的QQ相册的可行性分析
  • 对淘宝web旺旺版一些通讯接口的研究

Animation与Interpolator及AnimationSet的用法

posted by David Chen at May 6, 2009, 5:22 PM    

一、动作有很多种,AlphaAnimation, AnimationSet, RotateAnimation, ScaleAnimation, TranslateAnimation
例子:
TranslateAnimation ta = new TranslateAnimation( 2, 200, 2, 2);
// 位置由 [2,2] 到 [200,2]移动
imgView.setAnimation( ta );
ta.setDuration( 2000 );
// 设置 持续时间为2秒
//ta.setStartTime( 1000 );
// 设置1秒后启动
ta.setInterpolator( new AccelerateInterpolator((float) 0.2) );

二、动作特效:
Interpolator 定义了动画的变化速度,可以实现匀速、正加速、负加速、无规则变加速等;
Interpolator 是基类,封装了所有 Interpolator 的共同方法,它只有一个方法,即 getInterpolation (float input),该方法 maps a point on the timeline to a multiplier to be applied to the transformations of an animation.

AccelerateDecelerateInterpolator, AccelerateInterpolator, CycleInterpolator, DecelerateInterpolator, LinearInterpolator
AccelerateDecelerateInterpolator,延迟减速,在动作执行到中间的时候才执行该特效。An interpolator where the rate of change starts and ends slowly but accelerates through the middle.
AccelerateInterpolator, 会使慢慢以(float)的参数降低速度。An interpolator where the rate of change starts out slowly and and then accelerates.
LinearInterpolator,平稳不变的,An interpolator where the rate of change is constant。
DecelerateInterpolator,在中间加速,两头慢,An interpolator where the rate of change starts out quickly and and then decelerates.
CycleInterpolator,曲线运动特效,要传递float型的参数。Repeats the animation for a specified number of cycles. The rate of change follows a sinusoidal pattern.

//ta.setRepeatMode( Animation.REVERSE );
ta.setRepeatCount( 0 );

三、 setRepeatMode参数应是Animation.RESTART或Animation.REVERSE或Animation.INFINITE,
设置动作结束后,将怎样处理,默认是Animation.RESTART,回到动作开始时的坐标
setRepeatCount(repeatCount),参数是Animation.INFINITE则表示不断重复该动作,
只有在repeatCount大于0或为INFINITE的时候setRepeatMode才会生效。
REVERSE是反转的意思,如果repeatCount大于1,repeatMode为Animation.REVERSE
那么动作将会回来不断执行,即由a点去到b点后,会从b点和原来的动作相反的相同时
间回到a点,依此类推,即是说REVERSE也算入repeatCount。

四、AnimationSet 可以包含多个Animation,但都是在同一个时间执行的,是并行,不是串行执行的。
如果AnimationSet中有一些设定,如duration,fillBefore等,它包含的子动作也设定了的话,
子动作中的设定将会给覆盖掉。
If AnimationSet sets any properties that its children also set (for example, duration
or fillBefore), the values of AnimationSet override the child values.

AnimationSet as = new AnimationSet( true );
as.addAnimation( ta );
TranslateAnimation t1 = new TranslateAnimation( 2, 200, 8, 300);
t1.setDuration( 2000 );
as.addAnimation( t1 );
RotateAnimation r1 = new RotateAnimation( (float) 1, (float) 0.1 );
r1.setDuration( 2000 );
//as.addAnimation( r1 );
imgView.setAnimation(as);
//as.setDuration( 6000 );
//as.setStartTime( 1000 );
as.start();
Labels:   Java    Android  
Trackback:   http://cwq.iou1314.com/animation-interpolator_a366
微博最近更新
[2010-07-31 16:33]    今天下午又将昨天赢的哎齐出来了,郁闷,一进一出,要有入没出才行啊。
[2010-07-31 07:40]    昨晚又去啊泄度开台,呢次赢左差唔多3旧水,下周星期一请假,回郁南去转社保和入党资料。
本站内的任何文章,只代表个人意见或学习所用,如有版权声明,请尊重作者的劳动成果,在转载时请保留原始链接并注明出处。
Power by David's PhpCms, © 2007 - 2010 CWQ.IOU1314.COM All Rights Reserved.