To simply debugging of my custom View, I'm trying to draw a border
around it so I can see its exact size/position.
The left and right sides of the border draw correctly, but the top and
bottom end up outside the screen by about 50 pixels.
My guess is that canvas.getHeight() isn't accounting for the
notification bar at the top. What am I doing wrong?
Here's my code:
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
Log.w("", "canvas bounds:" + canvas.getClipBounds() + ", width/
height: " + canvas.getWidth() + ", " + canvas.getHeight());
//draw border
canvas.drawLine(0, 0, canvas.getWidth(), 0, mBorderPaint);
canvas.drawLine(canvas.getWidth(), 0, canvas.getWidth(),
canvas.getHeight(), mBorderPaint);
canvas.drawLine(canvas.getWidth(), canvas.getHeight(), 0,
canvas.getHeight(), mBorderPaint);
canvas.drawLine(0, 0, 0, canvas.getHeight(), mBorderPaint);
}
Here's the output of the log statement:
10-24 02:01:35.488: WARN/(1300): onDraw called: canvas bounds:Rect(0,
0, 320, 430), width/height: 320, 480
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---