Is there a way to adjust the spacing between characters in an Android TextView? I believe this is typically called \"kerning\".
I\'m aware of the
If anyone is looking for a simple way to apply the kerning to any string (technically, CharSequence) without using a TextView:
public static Spannable applyKerning(CharSequence src, float kerning)
{
if (src == null) return null;
final int srcLength = src.length();
if (srcLength < 2) return src instanceof Spannable
? (Spannable)src
: new SpannableString(src);
final String nonBreakingSpace = "\u00A0";
final SpannableStringBuilder builder = src instanceof SpannableStringBuilder
? (SpannableStringBuilder)src
: new SpannableStringBuilder(src);
for (int i = src.length() - 1; i >= 1; i--)
{
builder.insert(i, nonBreakingSpace);
builder.setSpan(new ScaleXSpan(kerning), i, i + 1,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
return builder;
}