@Ichorus's answer is correct for views, but if you want to draw rotated rectangles or text, you can do the following in the onDraw (or onDispatchDraw) callback for your view:
(note that theta is the angle from the x-axis of the desired rotation, the rotation axis is the point that represents the point around which we want the rectangle to rotate, and horizontalRect is the direct position "before it was rotated)
canvas.save(); canvas.rotate(theta, pivot.x, pivot.y); canvas.drawRect(horizontalRect, paint); canvas.restore();
gauravjain0102 Dec 26 '11 at 11:03 2011-12-26 11:03
source share