Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
int xPos = (canvas.getWidth() / 2);
int yPos = (int) ((canvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2)) ;
//((textPaint.descent() + textPaint.ascent()) / 2) is the distance from the baseline to the center.
canvas.drawText("Hello", xPos, yPos, textPaint);
https://stackoverflow.com/a/38415380
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment