Created
March 11, 2016 09:16
-
-
Save yuanliwei/c153421d6562709ca9de to your computer and use it in GitHub Desktop.
Android drawText 文字垂直居中
This file contains hidden or 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
| float textWidth = paintOval.measureText(progressText); | |
| Paint.FontMetricsInt fmi = paintOval.getFontMetricsInt(); | |
| float left = (width - textWidth) / 2; | |
| float top = (height - fmi.bottom - fmi.top) / 2; | |
| canvas.drawText(progressText, left, top, paintOval); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment