Retrieve line spacing in TextView - Android

会有一股神秘感。 提交于 2019-12-11 07:38:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!