Is it possible to style the android fonts styles with leading and tracking?

╄→гoц情女王★ 提交于 2019-12-20 09:38:00

问题


Is it possible to have the followings in android font styling.

  1. Leading (the space vertically between lines of text - name comes from the physical piece of lead that used to be used in mechanical printing process to separate lines of text).

  2. Tracking (the horizontal space between each character).

If you have any ideas please share with me.


回答1:


  1. You can change leading by calling TextView's method setLineSpacing() or changing corresponding XML attributes of TextView in layout (android:lineSpacingExtra or android:lineSpacingMultiplier).

  2. As answered here:

AFAIK, you cannot adjust kerning in TextView. You may be able to adjust kerning if you draw the text on the Canvas yourself using the 2D graphics APIs.

Update: since API 21 there is an option to set kerning/tracking/letter spacing. You can call method setLetterSpacing() or set it in XML with attribute letterSpacing.




回答2:


For Tracking, check out this answer. It works fine for me.



来源:https://stackoverflow.com/questions/5620325/is-it-possible-to-style-the-android-fonts-styles-with-leading-and-tracking

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