我想使用Html.fromHtml()打开url,标签之间的特定文本应该是绿色的,而不是下划线。
我现在怎么做才能做到这一点呢?
consent = consent.replace("<clickable>", "<a href=\"https://www.google.com/\"").replace("</clickable>", "</a>");
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
consentCheck.setText(Html.fromHtml(consent, Html.FROM_HTML_MODE_LEGACY));
} else {
consentCheck.setText(Html.fromHtml(consent));
}发布于 2018-03-01 15:49:29
您是否尝试过:
textView.setMovementMethod(LinkMovementMethod.getInstance());要更改颜色:
String blue = "this is blue";
SpannableString blueSpannable = new SpannableString(blue);
blueSpannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, blue.length(), 0);
builder.append(blueSpannable);
mTextView.setText(builder, BufferType.SPANNABLE);https://stackoverflow.com/questions/49044879
复制相似问题