动画师和动画有什么区别? [英] What is the difference between an Animator and an Animation?

查看:491
本文介绍了动画师和动画有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动画动画师允许我对对象的属性(位置,不透明度,比例,旋转度等)进行动画处理,并且很难区分两者的用例.什么时候应该使用动画师而不是动画,反之亦然?

It looks like both Animations and Animators allow me to animate properties (position, opacity, scale, rotation, etc) on objects, and I'm having a hard time differentiating between the use case for both. When should I use an animator versus an animation and vice versa?

推荐答案

AnimationsAnimators的旧版本.在3.0中引入了动画师,以帮助克服动画的一些缺点.

Animations are older versions of Animators. Animators where introduced in 3.0 to help overcome some short-coming that Animations have.

Animations仅更改对象的视觉表示.如果您只是更改不透明度,这很好,但是在平移,旋转或缩放对象时会引起问题.在Animators之前的过去,如果平移了对象,则必须使用新坐标进行重新布局.根据对象移动的位置,可能会非常困难.

Animations only change the visual representation of an object. This is fine if you're just changing opacity, but it causes issues when you translate, rotate, or scale objects. In the old days before Animators, if you translated the object, you had to perform a re-layout with the new coordinates. It could be rather difficult depending on where the object moved.

另一方面,动画师会更改对象的物理属性.这意味着,如果将视图移动到新位置,则触摸坐标将被映射到新位置,而无需任何其他干预.

Animators on the other hand change the physical properties of the objects. This means that if you move a View to a new location, the touch coordinates will be mapped at the new location without any other intervention.

就我个人而言,除非我使用API​​的2.3或更低版本进行开发,否则我将不再使用动画.幸运的是,这已不再是一个问题.还有一些旧的类仍在使用Animations API,尤其是在使用xml资源时,例如android.support.v4.app.FragmentTransaction类(普通的FragmentTransaction支持Animators).

Personally, I don't use Animations much anymore unless I'm developing at API's 2.3 or less. Thankfully that's becoming less of an issue. There are also some old classes that still use Animations API especially when it comes to using xml resources such as the android.support.v4.app.FragmentTransaction class (the normal FragmentTransaction supports Animators instead).

作为旁注,项目 NineOldAndroids 的开发目的是模仿Animators的功能,但是使用Animations可以制作应用程序一直到1.6.

As a side note, the project NineOldAndroids was developed to mimic functionality of Animators but using Animations so you can make apps that work all the way to 1.6.

这篇关于动画师和动画有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆