Created
September 5, 2021 07:32
-
-
Save piyush-malaviya/1616d056b5f71b14267acd110e5a0a3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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