Search code examples
androidtextandroid-canvasdraw

Measuring text width to be drawn on Canvas ( Android )


Is there a method which returns the width ( in pixels ) of a text to be drawn on an Android canvas using the drawText() method according to the Paint used to draw it?


Solution

  • Have you looked at android.graphics.Paint#measureText(String txt)?