0

我还想url使用Html.fromHtml()标签之间的特定文本打开,应该是绿色而不是下划线。

我现在怎么能这样做我正在这样做:

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));
}
4

1 回答 1

0

你有没有尝试过 :

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);
于 2018-03-01T07:49:28.580 回答