15

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.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
Joshua
  • 442
  • 1
  • 5
  • 20

2 Answers2

11
  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.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
  • Great, thanks! `android:lineSpacingMultiplier="1.15"` with a Roman (i.e., "serif") typeface makes any length of text much more readable. – JohnK Jun 28 '12 at 22:12
  • For leading, #1 here works but can cause alignment issues. It appears the text element is grown below the visible text by the amount of leading, which causes the text to be shifted to a higher position on the screen. This causes single lines of text that may be centered vertically with other UI elements to not aligned so nicely. Have 3dp of leading, you may need to add 3dp of lower padding to those other UI elements. Still, the increased leading is, in fact, much more readable. – javahead76 Jul 10 '13 at 12:47
1

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

Community
  • 1
  • 1
Pedro Barros
  • 1,326
  • 1
  • 12
  • 19