问题
How can I retrieve the line spacing values (as currently applied to a piece of text) in a TextView? In API 16 and above, the appropriate functions to call would be getLineSpacingExtra() and getLineSpacingMultiplier(). What are the appropriate functions for API version less than 16?
回答1:
Looking at the source of TextView as given here shows that getLineHeight returns an integer for the line height whose 'formula' is given as:
lineHeight = FastMath.round(mTextPaint.getFontMetricsInt(null) * mSpacingMult
+ mSpacingAdd);
mSpacingMult and mSpacingAdd can be set with setLineSpacing(float mult, float add). Both these functions are available since API Level 1.
来源:https://stackoverflow.com/questions/19755405/retrieve-line-spacing-in-textview-android