Animation and Graphics Overview

来源:互联网 发布:linux开机启动流程 编辑:程序博客网 时间:2024/05/16 12:17

Animation and Graphics Overview

Android provides a variety of powerful APIs for applying animation to UI elements and drawing custom 2D and 3D graphics. The sections below provide an overview of the APIs and system capabilities available and help you decide with approach is best for your needs.

Android提供了各种功能强大的api将动画应用于UI元素和绘制自定义2 d和3 d图形。以下章节提供一个api和系统有效性能的综述,并帮助你决定最接近您需要。

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中引入的)和视图动画。动画系统都是可行的选择,但房地产动画系统,一般来说,使用是首选方法,因为它更灵活和提供了更多的功能。除了这两个系统中,您可以利用可绘制的动画,你可以加载可绘制的资源并显示他们一帧又一帧。

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.
视图动画是旧系统和只能用于视图。它相对容易设置和提供足够的能力来满足许多应用程序的需求。
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 resources来呈现,如一个进度bitmap。

2D and 3D Graphics

When writing an application, it's important to consider exactly what your graphical demands will be. Varying graphical tasks are best accomplished with varying techniques. For example, graphics and animations for a rather static application should be implemented much differently than graphics and animations for an interactive game. Here, we'll discuss a few of the options you have for drawing graphics on Android and which tasks they're best suited for.

编写一个应用程序时,考虑准确的图形化要求是什么是重要的。不同的图形用不同的技术完成。例如,一个静态的应用的图形和动画实施起来是不同于游戏的图形和动画。在这里,我们将讨论几个选项的绘制图形在Android上,他们最适合的任务。

Canvas and Drawables
Android provides a set of View widgets that provide general functionality for a wide array of user interfaces. You can also extend these widgets to modify the way they look or behave. In addition, you can do your own custom 2D rendering using the various drawing methods contained in the Canvas class or create Drawableobjects for things such as textured buttons or frame-by-frame animations.
Android提供了一组视图部件,提供一系列广泛的用户界面的功能。你也可以扩展这些小部件来修改他们的外观或行为。此外,你可以做您自己的自定义2 d渲染使用各种绘图方法包含在Canvas类或为某件东西创建Drawableobjects诸如变形按钮或逐帧动画。
Hardware Acceleration
Beginning in Android 3.0, you can hardware accelerate the majority of the drawing done by the Canvas APIs to further increase their performance.
开始在Android 3.0中,您可以硬件加速的大部分绘制通过Canvas的api来进一步提高其性能。
OpenGL
Android supports OpenGL ES 1.0 and 2.0, with Android framework APIs as well as natively with the Native Development Kit (NDK). Using the framework APIs is desireable when you want to add a few graphical enhancements to your application that are not supported with the Canvas APIs, or if you desire platform independence and don't demand high performance. There is a performance hit in using the framework APIs compared to the NDK, so for many graphic intensive applications such as games, using the NDK is beneficial (It is important to note though that you can still get adequate performance using the framework APIs. For example, the Google Body app is developed entirely using the framework APIs). OpenGL with the NDK is also useful if you have a lot of native code that you want to port over to Android. For more information about using the NDK, read the docs in the docs/ directory of the NDK download.
Android支持OpenGL ES 1.0和2.0,与本地Android框架api以及本机开发工具包(NDK)。使用框架api有必要当您想要添加一些图形增强您的应用程序,该应用不支持的Canvas的api,或者如果你渴望平台独立性和不要求高性能。这里有一个性能的比较在框架api和 NDK之间,许多图形加强型应用程序如游戏,使用NDK是有益的(需要注意的是虽然你仍然可以使用这个框架api获得足够的性能。例如,谷歌的body app完全使用该框架的api)。用NDK的OpenGL也很有用,如果你有很多的本地代码,你想端口到Android。关于使用NDK的更多信息,读取文档的文档/目录NDK download





0 0
原创粉丝点击