2

How can I output text Right to Left (i.e. in reverse order) using Canvas.drawText ? Is there a way?

yydl
  • 24,284
  • 16
  • 65
  • 104

2 Answers2

1

Set Paint.Align property in your textPaint object, if you set it RIGHT -- The text is drawn to the left of the x,y origin:

textPaint.setTextAlign(Paint.Align.RIGHT);
canvas.drawText("your text here", getRight(), getY()/2, textPaint);
Michael
  • 3,308
  • 5
  • 24
  • 36
Kavis
  • 98
  • 4
-1

Check this out: How to draw RTL text (Arabic) onto a Bitmap and have it ordered properly?

Community
  • 1
  • 1
iluxa
  • 6,941
  • 18
  • 36
  • But how do you "use manual BiDi"? In other words, assuming I can detect that I should be going to right to left, how do I tell the drawText function to output the text in reverse? – yydl Apr 07 '11 at 22:28
  • And no solution on the link too – Vitaly May 28 '23 at 10:22