Posts

Showing posts from October, 2012

Drawing using Canvas in Android

In This tutorials We learn that how you can draw Images using canvas technology. canvas used for drawing geometrical shapes. Painting the shape using paint object . and it also used for drawing bitmap images. Fist of all we create inner class and extend it from View class. Now we override the onDraw() method of View class. all the drawing are implemented in the onDrea(Canvas c) method. In setContentView() write the new class name to set customize View instead of layout view Now let the fun Start public class CanvasTesting extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState) setContentView(new Panel(this)); } //inner class extending View class Panel extends View { private Bitmap myBm; private Canvas cc; private Handler hand=new Handler(); private int x=0; public Panel(Context