i have a text called Hello
now i need to apply fontsize for this say 12 or 18 now as soon as we apply font to the text the text size increases.
so now i
You can get the text height from the FontMetrics. It is constant for a particular font and font size, no matter what the current text string is.
Paint.FontMetrics fm = mTextPaint.getFontMetrics();
float textHeight = fm.descent - fm.ascent;
float lineHeight = fm.bottom - fm.top + fm.leading;
See my fuller answer here. I compare getTextBounds
with FontMetrics
in that answer.