How can I translate canvas after rotation to keep a rectangle in the center of another in android?

view story

http://stackoverflow.com – I want to be able to draw text and rectangles to the canvas after I have rotated them along their center. So I am making a test case where I have a blue square that does not get rotated, and a red square that should be rotated. THey are the same size, and should share the same center "pivot point". I have the following code: Paint p = new Paint(); p.setColor(Color.CYAN); p.setAlpha(200); canvas.drawRect(new Rect(100,100,300,300), p); canvas.save(); canvas.rotate(45,250,250);// 250,250 is the center of the blue rectangle p.setColor(Color.RED); p.setAlpha(100) (HowTos)