我想使用Html.fromHtml()
方法将颜色设置为部分文本。设置TextView的部分文字颜色?
我的代码是
String name = "<font color=\"#B034A2\">" + notificationListBean.getUsername() + "</font>"
textview.setText(Html.fromHtml(name));
但文本颜色没有改变。
我也试过,但这个也没有工作
Spannable wordtoSpan = new SpannableString(name);
wordtoSpan.setSpan(new ForegroundColorSpan(context.getResources().getColor(R.color.noti_color)), 0, name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textview.setText(wordtoSpan);
我应该怎么做什么样的变化?
你确定'textview'显示在屏幕上吗? – Blackbelt
是的,但颜色没有改变 –
发表更多代码。 – Blackbelt