James Liu
- Forum posts: 15
Apr 30, 2011, 8:24:59 PM via Website
Apr 30, 2011 8:24:59 PM via Website
Android provide a full functions on Graphics. Commonly, we can use 2D graphics library and OpenGL ES 1.0 for 3D graphic. In this post, I gonna to introduce the 2D graphics, and give you a 2D graphics canvas example.
Usually, when we try to draw 2D graphics, as android developer page say, we have two ways to choose:
Draw graphics directly to a Canvas is a little bit complicated. You can go to the android developer page for farther details. The following example will show you how to draw a bitmap on the canvas, when you click the canvas.
As android dev guide says, when you’re writing an application in which you would like to perform specialized drawing and/or control the animation of graphics, you should do so by drawing through a Canvas. When we do so, we will put our drawing code in onDrwa() callback method, and Canvas will be pass from the function parameter. And we also can get a canvas by calling SurfaceHolder.lockCanvas();
Here is a code example, apk file and source code:
Android Canvas Example
Hopeful, it will be helpful.
Usually, when we try to draw 2D graphics, as android developer page say, we have two ways to choose:
- Draw your graphics or animations into a View object from your layout.
- Draw your graphics directly to a Canvas.
Draw graphics directly to a Canvas is a little bit complicated. You can go to the android developer page for farther details. The following example will show you how to draw a bitmap on the canvas, when you click the canvas.
As android dev guide says, when you’re writing an application in which you would like to perform specialized drawing and/or control the animation of graphics, you should do so by drawing through a Canvas. When we do so, we will put our drawing code in onDrwa() callback method, and Canvas will be pass from the function parameter. And we also can get a canvas by calling SurfaceHolder.lockCanvas();
Here is a code example, apk file and source code:
Android Canvas Example
Hopeful, it will be helpful.
— modified on May 1, 2011, 2:46:23 PM
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.