Using PHP pspell Spell Check Functions with a Custom Dictionary
Enforce Coding Standards with PHP_CodeSniffer and Eclipse IDE on Ubuntu Linux
Tank Wars in G3D
A Simple ISAPI Filter for Authentication on IIS
Installing Xdebug for use with Eclipse or Netbeans on Linux
ENUMs, User Preferences, and the MySQL SET Datatype

Starting Android Graphics

Sunday, 21 October 12, 1:00 pm
Android applications are made up of instances of the Activity class. How an Activity displays information to the user is determined by its view. For text-style applications, this view is defined by an XML layout file. These files are fine for defining mostly static arrangements of display elements.

Graphical applications, such as games, need a more flexible mechanism so that elements may be freely placed anywhere on screen, and animated by changing their position. The solution is to create a programmatic layout by extending the View class.
public class graphicLayout extends View { }
On every frame, the onDraw() method of the View class is called. It receives a parameter of type Canvas, which represents the device's screen area. Override this method to draw the shapes required by your app, by calling the method on Canvas for the particular shape primitive you wish to draw:
protected void onDraw(Canvas canvas) { super.onDraw(canvas);   Paint rectStyle = new Paint(); rectStyle.setColor(Color.BLUE);   canvas.drawRect(new Rect(10, 10, 30, 20), rectStyle); }
The android developer documentation puts it like this: "To draw something, you need 4 basic components: A Bitmap to hold the pixels, a Canvas to host the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, Path, text, Bitmap), and a Paint (to describe the colours and styles for the drawing)".

Please enter your comment in the box below. Comments will be moderated before going live. Thanks for your feedback!

Cancel Post

/xkcd/ Bridge Clearance