I’m trying to rotate my subclass of TextView using canvas.rotate():
canvas.save();
final int w = getWidth();
final int h = getHeight();
float px = w/2f;
float py = h/2f;
canvas.rotate(mAngle, px, py);
super.draw(canvas);
canvas.restore();
TextView is rotated, however bounds of my view are clipped:

I understand that this is because of my view’s size – it is not changed during rotation while it should. But if I’ll change width\height in onMeasure problem will remain – I’m using LayoutParams.WRAP_CONTENT, so TextView just change it’s size according to values provided in setMeasuredDimensions.
How can I solve this problem?
At the first look solution provided by G. Blake Meike is a good way to start, however there is a lot of problems upcome.
To overcome problems there is an another way. It’s quite simple, but generally shouldn’t be used (since I’ve just deleted unneccesary for me stuff from original android source). To take control over drawing of concrete
Viewyou can overridedrawChildmethod of it’s parent (yes, you need your own subclass ofViewGroupor something more concrete likeFrameLayout). Here is an example of my solution:Main idea is that I’m granting non-clipped canvas to child.