Created
November 5, 2018 04:24
-
-
Save foundkey/e189243bcd6e3c9ee3eba335d9dafcf4 to your computer and use it in GitHub Desktop.
Calc Text bound
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
String str = "Hello World"; | |
Paint calcTextRect = new Paint(); | |
String familyName = “宋体”; | |
Typeface font = Typeface.create(familyName,Typeface.BOLD); | |
calcTextRect.setTypeface(font); // 设置字体 | |
calcTextRect.setColor(Color.RED); // 设置颜色 | |
calcTextRect.setTextSize(22); // 设置字体大小 | |
Rect rect = new Rect(); | |
calcTextRect.getTextBounds(str, 0, 1, rect); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment