How to Make a Canvas on an Android
Android developers need something called a "canvas" to draw graphics onto the screen. The graphics are drawn onto a bitmap, which holds the pixels comprising the canvas drawing. To create a canvas, you must first create a new bitmap. You can then create your canvas using a line of code. Adding a canvas to an Android application involves just a few steps.
Instructions
-
-
1
Open the source for your application in the Eclipse development environment.
-
2
Place your cursor in the code where want to create your new canvas.
-
-
3
Insert the following line of code to create your bitmap:
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
-
4
Enter this line of code directly below the line from Step 3:
Canvas c = new Canvas(b);
This creates the new canvas on the bitmap. You've successfully created a canvas on Android.
-
1