Android to TextView content add jump no underline

Source: Internet
Author: User

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());

Customizing a 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        }    }

Android to TextView content add jump no underline

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.