// Create spannable text and set style.
Spannable text = new SpannableString("This is underline and bold text.");
text.setSpan(new UnderlineSpan(), 8, 17, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new StyleSpan(Typeface.BOLD), 22, 26, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
// Set spannable text in TextView.
TextView textView = (TextView) findViewById(R.id.text);
textView.setText(text);
不需要图书馆。您手机上可用的表情符号采用 UNICODE 编码。所需要做的就是将正确的 unicode(
int) 转换为字符串。这是所有 Unicode 表情符号的资源。将 unicode 翻译成字符串笑脸(kotlin 代码)
如果 Unicode 以字符串形式出现,那么您可以将其转换为
int:虽然 Pavel 的回答非常正确和准确(我赞成),但让我再扩展一下:
将此表中的http://apps.timwhitlock.info/emoji/tables/unicode 'U+' 替换为 '0x'。例如
'U+1F60A'在'0x1F60A'.所以你会得到一个 int
然后,你可以这样做:
在 TextView(或 EditText)中你会看到 😊 没有 Drawable
http://developer.alexanderklimov.ru/android/theory/spannable.php