Setting up Paint for text

suggest change

Text drawing settings

Note that you can use TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, size, getResources().getDisplayMetrics()) to convert from SP or DP to pixels.

Measuring text

String text = "Hello world!";
Rect bounds = new Rect();
paint.getTextBounds(text, 0, text.length(), bounds);

There are other methods for measuring, however these three should fit most purposes.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents