如何从草图值计算 TextView 的字母间距? [英] How to calculate letterSpacing for TextView from sketch values?

查看:28
本文介绍了如何从草图值计算 TextView 的字母间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设计中,我有一个文本字段,文本大小为 16,字符间距为 0.6

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

但是,如果我为 TextViewandroid:letterSpacing 属性设置这个值,间距将比设计中的要大得多.

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

那么,如何将草图值转换为android值?

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

推荐答案

根据 Romain Guy 的说法,Android 使用1 em = 字体大小"定义,因此您只需执行

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

setLetterSpacing(characterSpacing / textSize)

...只要确保这些值的单位相同(dp vs px)

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

这篇关于如何从草图值计算 TextView 的字母间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆