TextView中部分字体高亮显示

方法一:

        TextView tv = new TextView(this);
        tv.setText(Html.fromHtml ("<font color=/"#ff0000/">红色</font>其它颜色"));

 

方法二:

        String content = "测试测试我我是是 是]我,,,,,";
        SpannableStringBuilder styled = new SpannableStringBuilder(content);
        styled.setSpan(new ForegroundColorSpan(Color.BLUE), 1, content.lastIndexOf("]"),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv.setText(styled);

你可能感兴趣的:(String,测试)