android之animator 和animation 的区别

作者&投稿:示相 (若有异议请与网页底部的电邮联系)
animation和animator的区别~

二者的区别是:
animation意思是生气,活泼;动画片制作,动画片摄制;动画片。
animator意思是动画片绘制者。
例句辨析:
animation
1、The films are a mix of animation and full-length features.
这些电影将动画制作和长篇故事片融为一体。
2、This film is the first British animation sold to an American network.

这是第一部出售给美国电视网的英国动画片。
3、They both spoke with animation.

他们兴致勃勃地说着。

animator
1、This specifies the attribute on which the animator will operate.
该属性指定动画将在哪个属性上进行操作。
2、Makoto Shinkai is a Japanese anime director, animator, and principal voice actor.

新海诚是日本著名的动画导演、动画家和声优。
3、What skills do you think are important to be a successful animator?
你认为成为一个成功的动画人,哪些技能是重要的呢?

animation
英 [ænɪ'meɪʃ(ə)n] 美 [,ænɪ'meʃən]
n. 活泼,生气;激励;卡通片绘制
animator
英 ['ænɪmeɪtə] 美 ['ænə'metɚ]
n. 鼓舞者;赋与生气者;卡通片绘制者(等于animater)

一、 前言
Animator框架是Android 4.0中新添加的一个动画框架,和之前的Animation框架相比,Animator可以进行更多和更精细化的动画控制,而且比之前更简单和更高效。在4.0源码中随处都可以看到Animator的使用。

二、 Animation和Animator比较
如下图,是Animation和Animator两个类继承图的对比。
C:Object C:Object
C:Animation C:Animator
C:AlphaAnimation C:AnimatorSet
C:AnimationSet C:ValueAnimator
C:DummyAnimation C:ObjectAnimator
C:Rotate3dAnimation C:TimeAnbimator
C:RotateAniamtion
C:ScaleAnimation
C:TranslateAnimation

Animation框架定义了透明度,旋转,缩放和位移几种常见的动画,而且控制的是一个整个View动画,实现原理是每次绘制视图时View所在的ViewGroup中的drawChild函数获取该View的Animation的Transformation值,然后调用canvas.concat(transformToApply.getMatrix()),通过矩阵运算完成动画帧,如果动画没有完成,继续调用invalidate()函数,启动下次绘制来驱动动画,动画过程中的帧之间间隙时间是绘制函数所消耗的时间,可能会导致动画消耗比较多的CPU资源。
在Animator框架中使用最多的是AnimatorSet和ObjectAnimator配合,使用ObjectAnimator进行更精细化控制,只控制一个对象的一个属性值,多个ObjectAnimator组合到AnimatorSet形成一个动画。而且ObjectAnimator能够自动驱动,可以调用setFrameDelay(longframeDelay)设置动画帧之间的间隙时间,调整帧率,减少动画过程中频繁绘制界面,而在不影响动画效果的前提下减少CPU资源消耗。

三、 关键接口介绍
1. ObjectAnimator介绍
Animator框架封装得比较完美,对外提供的接口非常简单,创建一个ObjectAnimator只需通过如下图所示的静态工厂类直接返回一个ObjectAnimator对象。传的参数包括一个对象和对象的属性名字,但这个属性必须有get和set函数,内部会通过java反射机制来调用set函数修改对象属性值。还包括属性的初始值,最终值,还可以调用setInterpolator设置曲线函数。

2. AnimatorSet介绍
AnimatorSet主要是组合多个AnimatorSet和ObjectAnimator形成一个动画,并可以控制动画的播放顺序,其中还有个辅助类通过调用play函数获得。

3. AnimatorUpdateListner介绍
通过实现AnimatorUpdateListner,来获得属性值发生变化时的事件,在这个回调中发起重绘屏幕事件。

四、 使用实例
在Android4.0中的ApiDemo中有个BouncingBalls实例,描述了Animator框架的使用,当点击屏幕时,绘制一个球从点击位置掉到屏幕底部,碰到底部时球有压扁的效果,然后回弹到点击位置再消失。
代码如下:
ShapeHolder newBall =addBall(event.getX(), event.getY());

// Bouncing animation with squash and stretch
float startY = newBall.getY();
float endY = getHeight() - 50f;
float h = (float)getHeight();
float eventY = event.getY();
int duration = (int)(500 * ((h - eventY)/h));
ValueAnimator bounceAnim = ObjectAnimator.ofFloat(newBall, "y", startY, endY);
bounceAnim.setDuration(duration);
bounceAnim.setInterpolator(new AccelerateInterpolator());
ValueAnimator squashAnim1 = ObjectAnimator.ofFloat(newBall, "x", newBall.getX(),
newBall.getX() - 25f);
squashAnim1.setDuration(duration/4);
squashAnim1.setRepeatCount(1);
squashAnim1.setRepeatMode(ValueAnimator.REVERSE);
squashAnim1.setInterpolator(new DecelerateInterpolator());
ValueAnimator squashAnim2 = ObjectAnimator.ofFloat(newBall, "width", newBall.getWidth(),
newBall.getWidth() + 50);
squashAnim2.setDuration(duration/4);
squashAnim2.setRepeatCount(1);
squashAnim2.setRepeatMode(ValueAnimator.REVERSE);
squashAnim2.setInterpolator(new DecelerateInterpolator());
ValueAnimator stretchAnim1 = ObjectAnimator.ofFloat(newBall, "y", endY,
endY + 25f);
stretchAnim1.setDuration(duration/4);
stretchAnim1.setRepeatCount(1);
stretchAnim1.setInterpolator(new DecelerateInterpolator());
stretchAnim1.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator stretchAnim2 = ObjectAnimator.ofFloat(newBall, "height",
newBall.getHeight(),newBall.getHeight() - 25);
stretchAnim2.setDuration(duration/4);
stretchAnim2.setRepeatCount(1);
stretchAnim2.setInterpolator(new DecelerateInterpolator());
stretchAnim2.setRepeatMode(ValueAnimator.REVERSE);
ValueAnimator bounceBackAnim = ObjectAnimator.ofFloat(newBall, "y", endY,
startY);
bounceBackAnim.setDuration(duration);
bounceBackAnim.setInterpolator(newDecelerateInterpolator());
// Sequence the down/squash&stretch/upanimations
AnimatorSet bouncer = new AnimatorSet();
bouncer.play(bounceAnim).before(squashAnim1);
bouncer.play(squashAnim1).with(squashAnim2);
bouncer.play(squashAnim1).with(stretchAnim1);
bouncer.play(squashAnim1).with(stretchAnim2);
bouncer.play(bounceBackAnim).after(stretchAnim2);

// Fading animation - remove the ball when theanimation is done
ValueAnimator fadeAnim = ObjectAnimator.ofFloat(newBall, "alpha", 1f, 0f);
fadeAnim.setDuration(250);
fadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animatoranimation) {
balls.remove(((ObjectAnimator)animation).getTarget());

}
});
// Sequence the two animations to play oneafter the other
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.play(bouncer).before(fadeAnim);

// Start the animation
animatorSet.start();


Android系统是什么?
安卓中文“安卓”是由“Android”音译过来的,所以说在中国“安卓”一词直接代表了Android手机操作系统。安卓的所有软件是APK格式的,APK是AndroidPackage的缩写,即Android安装包(anapk)。APK是类似SymbianSis或Sisx的文件格式。通过将APK文件直接传到Android模拟器或Android手机中执行即可安装。

android中怎么判断当前anctivity销毁了
在这个activity中添加一个状态标志,当被加载的时候修改这个状态标志的值,并将状态值返回给调用它的activity。

android是什么意思
android作名词时意思是机器人。作形容词时意思是有人类特征的。它还是一种操作系统名称,安卓系统(Google开发的基于Linux平台的手机操作系统)。英式读法是['ændrɔɪd];美式读法是['ændrɔɪd]。相关例句:1、用作名词 (n.)The cost of an android will be ...

android 启动虚拟设备时,始终有 an android virtual device that failed...
一开始吓死我了,你只管启动虚拟机,没事的耐心等等就好了

android怎么读
android [英]['ændrɔɪd][美][ˈænˌdrɔɪd]n.机器人;基于Linux平台的开源手机操作系统,主要使用于便携设备。目前尚未有统一中文名称,中国大陆地区较多人称为安卓 复数: androids 双语例句 1.If you want an Android phone right now, get a ...

安卓权限详细介绍
android.permission.CLEAR_APP_USER_DATA允许一个程序清除用户设置(Allows an application to clear user data)android.permission.CONTROL_LOCATION_UPDATES允许启用禁止位置更新提示从无线模块(Allows enabling\/disabling location updatenotifications from the radio. )android.permission.DELETE_CACHE_FILES允许程序删除缓存...

Android模拟器无法创建ADK出现An Android Virtual Device that failed...
JDK 安装目录不能有中文和空格!如果默认安装就装在C:\\Program Files\\Java...下面了,这个路径中Program 和Files之间是有空格的,这样不行的.建议选择其他目录安装java

开发安卓app(从入门到精通)
3.安装安卓虚拟机 安卓虚拟机是用来模拟安卓设备的软件,可以在AndroidStudio中下载并安装。二、创建第一个安卓app 1.创建新项目 打开AndroidStudio,点击“StartanewAndroidStudioproject”创建一个新的安卓项目。在“CreateNewProject”对话框中,填写项目名称、包名、项目路径等信息。2.选择模板 在“Addan...

An droid这是什么意思。
Android(['ændrɔid])是一个以Linux为基础的半开源操作系统,主要用于行动设备,由Google和开放手持设备联盟开发与领导。 Android 系统最初由安迪·鲁宾(Andy Rubin)制作,最初主要支持手机。2005年8月17日被Google收购。2007年11月5日,Google与84家硬件制造商、软件开发商及电信营运商...

android什么意思
3、Directed and co-written by Maria Schrader,this sci-firomancefeatures Maren Eggert as a divorced anthropologist14 who agrees to test-drive an android that is programmed to beher perfect partner.在这部由玛丽亚·施拉德担任导演并参与编剧的科幻爱情片中,一位离异的人类学家(玛伦·艾格特...

城北区18266669829: android之animator 和animation 的区别 -
表知富马: 你好.animator代表的是属性动画,改变的是 View属性的值;animation代表的是帧动画,不改变 View 属性的值.

城北区18266669829: android studio怎么新建动画animator文件 -
表知富马: android studio新建动画animator文件的方法打开android studio 右击res文件夹鼠标移动到New—>Android Resource File单击Resource Type三角下拉框选择Animator,然后输入文件名即可END 看了“android studio怎么新建动画animator文件”的人还看了1.Android Studio代码补全教程2.Android Studio怎么自动实现所有的接口函数3.Android Studio怎么设置文件编码4.Android Studio怎么自动为变量生成Get/Set函数

城北区18266669829: android animatorset playtogether 怎么使用 -
表知富马: 在写一个小动画时发现AnimatorSet没有setRepeatCount()与setRepeatMode()方法,但是动画效果又要求重复执行,这里提供的解决方法时:给动画集合中的子动画设置setRepeatCount(),想重复执行多少次动画就设置多少次,如果想...

城北区18266669829: Android studio怎么创建文件 -
表知富马: 1打开android studio 右击res文件夹2鼠标移动到New—>Android Resource File3单击Resource Type三角下拉框4选择Animator,然后输入文件名即可.5.clean一下工程文件.

城北区18266669829: 如何在Android开发中实现屏幕切换 -
表知富马: 屏幕切换指的是在同一个Activity内屏幕间的切换,最长见的情况就是在一个FrameLayout内有多个页面,比如一个系统设置页面;一个个性化设置页面.android.widget.ViewAnimator类继承至FrameLayout,ViewAnimator类的作用是为...

城北区18266669829: android如何在代码中创建屏幕元素? -
表知富马: 跟xml布局文件中相似,你可以自己继承自LinearLAyout写你得布局,或者其他布局也行,然后在setContentView中new 你写的这个LinearLayout就可以.在LinearLayout中通过addView添加你写的具体控件布局既可以.

城北区18266669829: android 自定义圆怎么动态设置圆的半径 -
表知富马: 使用ObjectAnimation,或者ValueAnimation都可以实现这个效果 ObjectAnimation可以动态设置控件有get与set方法的属性进行改变,给你的圆添加一个半径的属性,并添加get与set.参考//通过AnimatiorSet来设计同步执行的多个属性动画...

城北区18266669829: android objectanimator 旋转后内容相反怎么解决 -
表知富马: 解决方案:你可以添加一个AnimatorListener,动画结束时通知:原文:You can add an AnimatorListener, to be notified when the animation ends:scaleY.addListener(new AnimatorListener() { @Override public void onAnimationEnd(Animator ...

城北区18266669829: 如何在Android的切换方向锁定 -
表知富马: 在待机界面,从屏幕顶端往下拉,会看到一些常用菜单,找到屏幕锁定那个功能,横屏时候按锁定就是横屏,竖屏时候按锁定就是竖屏,不按锁定的话手机会根据使用方向自动切换横屏或者竖屏.

城北区18266669829: 安装什么库就可以使用android valueanimator -
表知富马: private int startX;private int endX; private void getLocation() {int[] startLocation = new int[2];startCityTextView.getLocationOnScreen(startLocation);int[] endLocation = new int[2];endCityTextView.getLocationOnScreen(endLocation);startX = startLocation[0];endX = endLocation[0];}

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网