title: How to rotate a rectangle drawn on canvas in Android?
body: <p>I am drawing a text on android canvas using the following piece of code</p>
  
  <pre><code>        Rect rect = new Rect();
          paint.getTextBounds(text, 0, text.length(), rect);
          canvas.translate(xPosition + position.getX(), yPosition + position.getY());
          paint.setColor(Color.BLUE);
          paint.setStyle(Style.STROKE);
          canvas.drawRect(rect, paint);
          paint.setStyle(Style.FILL);
          paint.setColor(text_color);
          canvas.translate(-(xPosition + position.getX()), -(yPosition + position.getY()));
          canvas.rotate(getDegreesFromRadians(angle), xPosition + position.getX() + rect.exactCenterX(), yPosition + position.getY() + rect.exactCenterY());
          canvas.drawText(text, xPosition + position.getX(), yPosition + position.getY(), paint);
  </code></pre>
  
  <p>This code takes care of the rotation of the text and it works fine. I am drawing a blue rectangle around the text using the above code. Now my problem is that the rectangle is not rotating along with the text. It still remains the same. Is there any way to rotate the rectangle drawn in android canvas?</p>