tags:

views:

43

answers:

1

canvas.drawRect(left, top, right, bottom, paint);

Say I want to draw rectangle

x=30 to x=35 of height y=50. What would be the values in above method. Thank you very much.

+1  A: 

Try:

canvas.drawRect(30,0,35,50,Reference_to_Paint_Object);

This is assuming that you want the rectangle to start at the top of the screen. Change the 2nd parameter to set the top location. You will also need to construct a Paint object to pass to the last parameter.

Josiah
Josiah,It is displaying at the very top left hand side of mobile, I want it to display at center of page. Is it that I will have to add something to force it to display at center.Actually, I am trying to generate series of pulses along x axis, hence would like to display them at middle of page. Thank you.
A couple of things to try: Check to make sure your canvas object is set to fill the area you have it in. Try bumping up the first parameter (which is the offset from the left-hand side of the screen) and the second parameter (which is the offset from the top of the screen). So if you wanted to display in the middle of a 100 by 100 pixel display, you would say drawRect(45,45,10,10,Paint_Object);
Josiah