If you do not use a fixed-width font as a courier, this is not easy.
There is no function that returns the position of letters for the source text and the required width in pixels. You will have to write it.
you should measure the text like here:
paint.setTypeface(Typeface.DEFAULT);
I would use some hash algorithm to find the right position
source share