Friday, 7 September 2012

Draw bitmap on canvas

Modify onDraw(Canvas canvas) method of MyView.java in the former exercise to draw bitmap on convas of our custom view.

 @Override
protected void onDraw(Canvas canvas) {

float w, h, cx, cy;
w = getWidth();
h = getHeight();
cx = w/2;
cy = h/2;

canvas.drawRect(0, 0, w, h, BackPaint);

Bitmap myBitmap = BitmapFactory.decodeResource(
getResources(),
R.drawable.ic_launcher);
canvas.drawBitmap(myBitmap, cx, cy, null);

};


Draw bitmap on canvas


download filesDownload the files.


Borneo08

About Borneo08

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :

More links

Related Posts Plugin for WordPress, Blogger...