Android TextView 右上角文字角标(TM, ©,® )
Posted 胖虎
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android TextView 右上角文字角标(TM, ©,® )相关的知识,希望对你有一定的参考价值。
两种实现方式:
// ============ Use html String ==========
TextView tvUseHtml = findViewById(R.id.tvUseHtml);
String htmlString = "This is use HTML string.<sup><small>Sina weibo</small></sup>";
tvUseHtml.setText(Html.fromHtml(htmlString));
// ============ Use SuperscriptSpan ==========
TextView tvUseSpan = (TextView) findViewById(R.id.tvUseSpan);
String baseString = "This is use SuperscriptSpan.";
String extendString = "Sina weibo";
SpannableStringBuilder cs = new SpannableStringBuilder(baseString + extendString);
int start = baseString.length();
cs.setSpan(new SuperscriptSpan(),
start,
start + extendString.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
cs.setSpan(new RelativeSizeSpan(0.75f),
start,
start + extendString.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tvUseSpan.setText(cs);
以上是关于Android TextView 右上角文字角标(TM, ©,® )的主要内容,如果未能解决你的问题,请参考以下文章