From e415557d24afd197d1901794c9206fb6ab50a871 Mon Sep 17 00:00:00 2001 From: Tim Su Date: Mon, 30 Jan 2012 00:49:35 -0800 Subject: [PATCH] Re-write custom border drawable to fit in the allocated space --- .../com/todoroo/astrid/ui/CustomBorderDrawable.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/ui/CustomBorderDrawable.java b/astrid/src/com/todoroo/astrid/ui/CustomBorderDrawable.java index ebccc21c5..083aa9d8e 100644 --- a/astrid/src/com/todoroo/astrid/ui/CustomBorderDrawable.java +++ b/astrid/src/com/todoroo/astrid/ui/CustomBorderDrawable.java @@ -25,14 +25,18 @@ public class CustomBorderDrawable extends ShapeDrawable { @Override protected void onDraw(Shape shape, Canvas canvas, Paint paint) { - shape.resize(canvas.getWidth(), canvas.getHeight()); - shape.draw(canvas, fillpaint); + shape.resize(canvas.getClipBounds().right, + canvas.getClipBounds().bottom); Matrix matrix = new Matrix(); - matrix.setRectToRect(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), - new RectF(strokeWidth/2, strokeWidth/2, canvas.getWidth() - strokeWidth/2, canvas.getHeight() - strokeWidth/2), + matrix.setRectToRect(new RectF(0, 0, canvas.getClipBounds().right, + canvas.getClipBounds().bottom), + new RectF(strokeWidth/2, strokeWidth/2, canvas.getClipBounds().right - strokeWidth/2, + canvas.getClipBounds().bottom - strokeWidth/2), Matrix.ScaleToFit.FILL); canvas.concat(matrix); + + shape.draw(canvas, fillpaint); shape.draw(canvas, strokepaint); }