TextView,EditText中添加不同颜色的文字

在很多时候,在我们项目里需要用到在一个TextView中要显示不同颜色的文字

private Spanned colorText(String text) {
return Html.fromHtml(String.format("<font color='#ff989e'>%1$s</font>", text));
}
//设置文字
textView.setText("01234")
textView.append(colorText("56789"));
这样就会在一个textView中显示两种颜色的文字了

posted @ 2016-09-26 11:26  TeddyYan  阅读(1670)  评论(0编辑  收藏  举报