我在论坛上找了一个答案,我试着这样做但是由于某种原因,颜色没有改变,有什么我做错了吗?
SpannableString wordtoSpan = new SpannableString(songSelected);
wordtoSpan.setSpan(
new ForegroundColorSpan(getResources().getColor(R.color.red)),
wordtoSpan.length()-1,
wordtoSpan.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
selected_song.setText("Selected song is: "+ wordtoSpan);
答案 0 :(得分:0)
像这样使用
String styledText = "This is <font color='red'>simple</font>.";
textView.setText(Html.fromHtml(styledText), TextView.BufferType.SPANNABLE);