`

【翻译】(74)动画

 
阅读更多

【翻译】(74)动画

 

see

http://developer.android.com/guide/topics/graphics/animation.html

 

原文见

http://developer.android.com/guide/topics/graphics/animation.html

 

-------------------------------

 

Animation

 

动画

 

-------------------------------

 

See also

 

另见

 

Property Animation 属性动画

View Animation 视图动画

Drawable Animation 可绘画对象动画

 

-------------------------------

 

The Android framework provides two animation systems: property animation (introduced in Android 3.0) and view animation. Both animation systems are viable options, but the property animation system, in general, is the preferred method to use, because it is more flexible and offers more features. In addition to these two systems, you can utilize Drawable animation, which allows you to load drawable resources and display them one frame after another.

 

Android框架提供两个动画系统:属性动画(在Android 3.0中引入)(注:github上有向后移植版,可以兼容2.1+,见https://github.com/laanwj/android-animation-backport)以及视图动画。两个动画系统都是可行的选择,但通常属性动画系统是首选的使用方法,因为它更灵活而且提供更多特性。在这两个系统之外,你可以利用Drawable动画,它允许你加载可绘画资源并且一帧接一帧地显示它们。

 

The view animation system provides the capability to only animate View objects, so if you wanted to animate non-View objects, you have to implement your own code to do so. The view animation system is also constrained in the fact that it only exposes a few aspects of a View object to animate, such as the scaling and rotation of a View but not the background color, for instance.

 

视图动画系统只提供动画化View对象的功能,所以如果你希望动画化非View对象,你不得不实现你自己的代码来做到这点。视图动画系统还被限制这样的事实,它只暴露一个要动画化的View对象的少量方面,诸如一个View的缩放和旋转,但背景颜色之类的则不能。

 

Another disadvantage of the view animation system is that it only modified where the View was drawn, and not the actual View itself. For instance, if you animated a button to move across the screen, the button draws correctly, but the actual location where you can click the button does not change, so you have to implement your own logic to handle this.

 

视图动画系统的另一个缺点是它只修改View被绘画在的地方,而不是实际View自身。例如,如果你动画化一个按钮以跨屏幕移动,那么按钮正确地绘画,但你可以点击按钮的实际位置并没有改变,所以你不得不实现你自己的逻辑以处理它。

 

With the property animation system, these constraints are completely removed, and you can animate any property of any object (Views and non-Views) and the object itself is actually modified. The property animation system is also more robust in the way it carries out animation. At a high level, you assign animators to the properties that you want to animate, such as color, position, or size and can define aspects of the animation such as interpolation and synchronization of multiple animators.

 

使用属性动画系统,这些限制被完全地移除,并且你可以动画化任意对象(View和非View)的任意属性而对象自身被实际地修改。属性动画系统也通过它解决动画的方式是变得更强壮。在更高的层面上,你赋予动画器到你希望动画化的属性,诸如颜色、位置、或大小,而且可以定义动画的切面诸如多动画器的插值和同步。

 

The view animation system, however, takes less time to setup and requires less code to write. If view animation accomplishes everything that you need to do, or if your existing code already works the way you want, there is no need to use the property animation system. It also might make sense to use both animation systems for different situations if the use case arises.

 

然而,视图动画系统花费更少的时间配置并且需要写较少的代码。如果视图动画实现你需要做的每一件事情,或者如果你的现存代码已经如你所愿地工作,那么没有必要使用属性动画系统。对不同的情形使用两种动画系统还可能有意义,如果该用例(注:用例是软件工程术语,指用非技术用语来描述用户的使用场景)出现。

 

Property Animation

 

属性动画

 

Introduced in Android 3.0 (API level 11), the property animation system lets you animate properties of any object, including ones that are not rendered to the screen. The system is extensible and lets you animate properties of custom types as well.

 

在Android 3.0(API级别11)中引入。属性动画系统让你动画化任意对象的属性,包括那些不被渲染到屏幕的对象。系统是可扩展的,也可以让你动画化自定义类型的属性。

 

View Animation

 

视图动画

 

View Animation is the older system and can only be used for Views. It is relatively easy to setup and offers enough capabilities to meet many application's needs.

 

视图动画是较旧的系统,只可以被用于View。它相对容易配置并且提供足够的能力来满足许多应用程序的需要。

 

Drawable Animation

 

可绘画对象动画

 

Drawable animation involves displaying Drawable resources one after another, like a roll of film. This method of animation is useful if you want to animate things that are easier to represent with Drawable resources, such as a progression of bitmaps.

 

可绘画对象动画一个接一个地调用正在显示的Drawable资源,就像一个滚动的胶卷(注:电影)。这种方法的动画是有用的,如果你希望动画化一些东西,它们较容易用Drawable资源呈现,诸如一些连续的位图。

 

Except as noted, this content is licensed under Apache 2.0. For details and restrictions, see the Content License.

 

除特别说明外,本文在Apache 2.0下许可。细节和限制请参考内容许可证。

 

Android 4.0 r1 - 08 Mar 2012 0:34

 

-------------------------------

 

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

 

(此页部分内容基于Android开源项目,以及使用根据创作公共2.5来源许可证描述的条款进行修改)

 

(本人翻译质量欠佳,请以官方最新内容为准,或者参考其它翻译版本:

* ソフトウェア技術ドキュメントを勝手に翻訳

http://www.techdoctranslator.com/android

* Ley's Blog

http://leybreeze.com/blog/

* 农民伯伯

http://www.cnblogs.com/over140/

* Android中文翻译组

http://androidbox.sinaapp.com/


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics