Breaking News
Loading...
Friday, 7 September 2012

Draw bitmap on canvas

09:55
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.


0 comments:

Post a Comment

 
Toggle Footer