index.jd revision d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03
19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpage.title=Graphics 29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project@jd:body 39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project<div id="qv-wrapper"> 59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project <div id="qv"> 6d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly <h2>Topics</h2> 79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project <ol> 8d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly <li><a href="{@docRoot}guide/topics/graphics/canvas.html">Canvas and Drawables</a></li> 9d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly <li><a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware Acceleration</a></li> 10d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly <li><a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL</a></li> 11a53afedf783176d531e7cf8744f9b07ce60a5c92Joe Fernandez </ol> 129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project </div> 139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project</div> 14a53afedf783176d531e7cf8744f9b07ce60a5c92Joe Fernandez 15d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<p>When writing an application, it's important to consider exactly what your graphical demands will be. 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source ProjectVarying graphical tasks are best accomplished with varying techniques. For example, graphics and animations 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectfor a rather static application should be implemented much differently than graphics and animations 18d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyfor an interactive game. Here, we'll discuss a few of the options you have for drawing graphics 19d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyon Android and which tasks they're best suited for. 209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project</p> 219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 22d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dl> 23d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dt><strong><a href="{@docRoot}guide/topics/graphics/2d-graphics.html">Canvas and 24d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert LyDrawables</a></strong></dt> 25d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dd>Android provides a set of {@link android.view.View} widgets that provide general functionality 26d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyfor a wide array of user interfaces. You can also extend these widgets to modify the way they 27d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lylook or behave. In addition, you can do your own custom 2D rendering using the various drawing 28d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lymethods contained in the {@link android.graphics.Canvas} class or create {@link 29d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyandroid.graphics.drawable.Drawable} objects for things such as textured buttons or frame-by-frame 30d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyanimations.</dd> 31d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly 32d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dt><strong><a href="{@docRoot}guide/topics/graphics/hardware-accel.html">Hardware 33d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert LyAcceleration</a></strong></dt> 34d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dd>Beginning in Android 3.0, you can hardware accelerate the majority of 35d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lythe drawing done by the Canvas APIs to further increase their performance.</dd> 36d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly 37d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dt><strong><a href="{@docRoot}guide/topics/graphics/opengl.html">OpenGL</a></strong></dt> 38d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly<dd>Android supports OpenGL ES 1.0 and 2.0, with Android framework APIs as well as natively 39d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lywith the Native Development Kit (NDK). Using the framework APIs is desireable when you want to add a 40d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyfew graphical enhancements to your application that are not supported with the Canvas APIs, or if 41d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyyou desire platform independence and don't demand high performance. There is a performance hit in 42d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyusing the framework APIs compared to the NDK, so for many graphic intensive applications such as 43d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lygames, using the NDK is beneficial (It is important to note though that you can still get adequate 44d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyperformance using the framework APIs. For example, the Google Body app is developed entirely 45d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lyusing the framework APIs). OpenGL with the NDK is also useful if you have a lot of native 46d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lycode that you want to port over to Android. For more information about using the NDK, read the 47d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lydocs in the <code>docs/</code> directory of the <a href="{@docRoot}sdk/ndk/index.html">NDK 48d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Lydownload.</a></dd> 49d2a4e69f3dffb85c256629f5ee9005d8b9d8ac03Robert Ly</dl> 509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 52