String url = data.blockChainUrl; //https or http url
SpannableStringBuilder builder = new SpannableStringBuilder("");
int start = builder.length();
String content = mContext.getResources().getString(R.string.block_chain_query); //填充字体颜色
builder.append(content);
int end = builder.length();
builder.setSpan(new URLSpanNoUnderline(url) {
@Override
public void onClick(View widget) {
super.onClick(widget);
}
}, start, end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
builder.setSpan(new ForegroundColorSpan(ContextCompat.getColor(mContext, R.color.color_a5ef44)), 0,
end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
mBlockChainQuery.setText(builder);
//必须有的set mBlockChainQuery.setMovementMethod(LinkMovementMethod.getInstance());
//自定义一个URLSpan
class URLSpanNoUnderline extends URLSpan {
public URLSpanNoUnderline(String url) {
super(url);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
//you self
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。