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);
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 酷酷鲨 设计师:CSDN官方博客 返回首页