7

I'm trying to build a custom clock view in Android. See image http://twitpic.com/1devk7

So far to draw the time and hour markers I have been using the Canvas.rotate method to get the desired effect. However, notice that it is difficult to interpret the numbers in the lower half of the clock (e.g. 6 or 9?) because of the angle in which they are drawn.

When using drawText, is it possible to draw the text at 45/90/180 degrees so that all text appears upright when my onDraw method has finished?

Some Guy
  • 15,854
  • 10
  • 58
  • 67
Damian
  • 8,062
  • 4
  • 42
  • 43

2 Answers2

34

To draw a text rotated by 90 degrees at point (x,y), use this code:

canvas.save();
canvas.rotate(-90, x, y);
canvas.drawText(text, x, y, paint);
canvas.restore();
Philippe
  • 506
  • 4
  • 3
4

How can you display upside down text with a textview in Android?

Community
  • 1
  • 1
Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
  • Thanks, I did already see this answer (and I'm already using Canvas.rotate) but I just realised that I can rotate about centre to find my drawing point and then rotate around my drawing point to draw my text at an angle. Don't know why that didn't occur to me before! Thanks. – Damian Apr 05 '10 at 18:14
  • Damian Can you explain it more please ? – Muhammad Shahab Jan 03 '11 at 07:20