在Android中更改首字母的字体 [英] Changing font of first letter in Android

查看:58
本文介绍了在Android中更改首字母的字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android中,是否有一种简单的方法来更改字符串或单词中第一个字母的字体?例如,我想对标题中每个单词的第一个字母使用奢侈的哥特式字体,然后将标题的其余部分使用较小的字体.

Is there an easy way to change the font of the first letter in a string or word in Android? For example, I'd like to use an extravagant gothic font for the first letter of every word in a title, and then have the rest of the title in a smaller font.

使用自定义的导入字体,因此不确定HTML标记是否可以工作.

Using custom imported fonts, so I'm not sure if HTML tags would work.

推荐答案

我最好的猜测是对 Spannable 使用不同的字体的第一个字母,并使用 TypefaceSpan .示例.

My best guess would be to use a Spannable for the first letter with a different typeface, using a TypefaceSpan. Example.

如果要使用自己的自定义字体,则应扩展TypefaceSpan .

If you want to use your own custom font, you should extend TypefaceSpan.

这篇关于在Android中更改首字母的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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