Calculating the height of text in Android
While Android has numerous methods for sizing text, as far as I can see, none of them let you pass in a max width to get the height of the text once it wraps.
This is relatively simple to do on iOS via – sizeWithFont:constrainedToSize:lineBreakMode:.
For Android, I came up with the following convenience method to do it:
With this, you can just do int height = getTextHeight("text", 160, 12.0f, Typeface.DEFAULT_BOLD); and you’re set.