Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Layout problem with Android: rotated TextView

I'm building an Android app on which I have to represent data in a Table-like format.
So I'm using TableLayout. The problem is that I have to draw a rotated string like in the following raw example:

alt text

How can I create my layout to be able to show the '2011' rotated?

like image 996
Cris Avatar asked Jan 08 '11 22:01

Cris


1 Answers

Extend the TextView class and override the onDraw method.

@Override
protected void onDraw(Canvas canvas) {
     canvas.save();
     canvas.rotate(90, xPivot, yPivot);
     super.onDraw(canvas);
     canvas.restore();

} 
like image 67
Cristian Avatar answered Sep 18 '22 19:09

Cristian