且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Android 中显示表情符号

更新时间:2022-12-11 14:14:57

我会尝试使用正则表达式将每个表情符号的所有出现替换为 <img> 标记.然后,将该 HTML 转换为 SpannedString 通过 Html.fromHtml().SpannedString 可以在 TextView 上的 setText() 调用中使用.

I would try using a regular expression to replace all occurrences of each emoticon with an <img> tag. Then, convert that HTML into a SpannedString via Html.fromHtml(). That SpannedString can be used in a setText() call on TextView.