Home | History | Annotate | Download | only in graphics
      1 page.title=Animation and Graphics Overview
      2 @jd:body
      3 
      4   <p>Android provides a variety of powerful APIs for applying animation to UI elements and drawing custom
      5   2D and 3D graphics. The sections below provide an overview of the APIs and system capabilities available
      6   and help you decide with approach is best for your needs.</p>
      7 
      8   <h3 id="animation">Animation</h3>
      9   
     10   <p>The Android framework provides two animation systems: property animation
     11   (introduced in Android 3.0) and view animation. Both animation systems are viable options,
     12   but the property animation system, in general, is the preferred method to use, because it
     13   is more flexible and offers more features. In addition to these two systems, you can utilize Drawable
     14   animation, which allows you to load drawable resources and display them one frame after
     15   another.</p>
     16 
     17 <dl>
     18 <dt><strong><a href="{@docRoot}guide/topics/graphics/prop-animation.html">Property
     19 Animation</a></strong></dt>
     20 <dd>Introduced in Android 3.0 (API level 11), the property animation system lets you
     21 animate properties of any object, including ones that are not rendered to the screen. The system is
     22 extensible and lets you animate properties of custom types as well.</dd>
     23 
     24 <dt><strong><a href="{@docRoot}guide/topics/graphics/view-animation.html">View
     25 Animation</a></strong></dt>
     26 <dd>View Animation is the older system and can only be used for Views. It is relatively easy to
     27 setup and offers enough capabilities to meet many application's needs.</dd>
     28 </dl>
     29 
     30 <dt><strong><a href="{@docRoot}guide/topics/graphics/drawable-animation.html">Drawable
     31 Animation</a></strong></dt>
     32 <dd>Drawable animation involves displaying {@link android.graphics.drawable.Drawable} resources one
     33 after another, like a roll of film. This method of animation is useful if you want to animate
     34 things that are easier to represent with Drawable resources, such as a progression of bitmaps.</dd>
     35 
     36 <h3 id="graphics">2D and 3D Graphics</h3>
     37 
     38 <p>When writing an application, it's important to consider exactly what your graphical demands will be.
     39 Varying graphical tasks are best accomplished with varying techniques. For example, graphics and animations
     40 for a rather static application should be implemented much differently than graphics and animations
     41 for an interactive game. Here, we'll discuss a few of the options you have for drawing graphics
     42 on Android and which tasks they're best suited for.
     43 </p>
     44 
     45 <dl>
     46 <dt><strong><a href="{@docRoot}guide/topics/graphics/2d-graphics.html">Canvas and
     47 Drawables</a></strong></dt>
     48 <dd>Android provides a set of {@link android.view.View} widgets that provide general functionality
     49 for a wide array of user interfaces. You can also extend these widgets to modify the way they
     50 look or behave. In addition, you can do your own custom 2D rendering using the various drawing
     51 methods contained in the {@link android.graphics.Canvas} class or create {@link
     52 android.graphics.drawable.Drawable} objects for things such as textured buttons or frame-by-frame
     53 animations.</dd>
     54 
     55 <dt><strong><a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware
     56 Acceleration</a></strong></dt>
     57 <dd>Beginning in Android 3.0, you can hardware accelerate the majority of
     58 the drawing done by the Canvas APIs to further increase their performance.</dd>
     59 
     60 <dt><strong><a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL</a></strong></dt>
     61 <dd>Android supports OpenGL ES 1.0 and 2.0, with Android framework APIs as well as natively
     62 with the Native Development Kit (NDK). Using the framework APIs is desireable when you want to add a
     63 few graphical enhancements to your application that are not supported with the Canvas APIs, or if
     64 you desire platform independence and don't demand high performance. There is a performance hit in
     65 using the framework APIs compared to the NDK, so for many graphic intensive applications such as
     66 games, using the NDK is beneficial (It is important to note though that you can still get adequate
     67 performance using the framework APIs. For example, the Google Body app is developed entirely
     68 using the framework APIs). OpenGL with the NDK is also useful if you have a lot of native
     69 code that you want to port over to Android. For more information about using the NDK, read the
     70 docs in the <code>docs/</code> directory of the <a href="{@docRoot}tools/sdk/ndk/index.html">NDK
     71 download.</a></dd>
     72 </dl>
     73 
     74