static void drawCentered (Canvas c, Rect r, Paint p) { float inset = p.getStrokeWidth () * 0.5f; if (inset == 0) { // catch hairlines inset = 0.5f; } c.drawRect (r.left + inset, r.top + inset, r.right - inset, r.bottom - inset, p); }