In recent projects, you need to use a custom control. There is a component to get the height of the drawing text, open the TextView source, there is a method Getlineheight ()
Public int getlineheight () { return fastmath.round (mtextpaint.getfontmetricsint (null) * Mspacingmult + Mspacingadd); }
Getlineheight's comments are as follows:
/**@return the height of one standard line in pixels. Note that markup* within the text can cause individual lines to being taller or shorter* than this height, and the layout may Contain additional first-* or last-line padding. */ returns the height of a row. Note the text inside the tag may be above or below this height, and the layout may contain additional first or last line filled portions.
We just get the height of a line of text and don't calculate the spacing.
so You can use Fastmath.round (Mtextpaint.getfontmetricsint (null)).
On the internet also found some ways to get text height by other means. After testing, it was found that the above method was used to get the most accurate height. The code for the test is not posted.