androidtextviewsketch-3

How to calculate letterSpacing for TextView from sketch values?


In design I have a text field with 16 as text size and 0.6 as character spacing

But, if I set this value for android:letterSpacing attribute of TextView spacing will be much more larger than in design.

So, what is the way to convert sketch value to android value?


Solution

  • According to Romain Guy, Android uses the "1 em = font size" definition, so you'd just do

    setLetterSpacing(characterSpacing / textSize)
    

    ...just make sure those values are in the same unit (dp vs px)