Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click without underline support #3

Open
neworld opened this issue Oct 12, 2017 · 1 comment
Open

Click without underline support #3

neworld opened this issue Oct 12, 2017 · 1 comment

Comments

@neworld
Copy link
Owner

neworld commented Oct 12, 2017

spanner.append("google", url("http://www.google.lt"), noUnderline())
@notHide
Copy link

notHide commented Oct 28, 2017

overriding the updateDrawState () in ClickableSpan, you can simply remove the underline.

code like this:

class ClickSpanBuilder(private val clickListener: OnClickListener) : SpanBuilder {

    override fun build(): Any {
        return EasyClickableSpan(this.clickListener)
    }

    private class EasyClickableSpan(private val clickListener: OnClickListener) : ClickableSpan() {

        override fun onClick(widget: View) {
            this.clickListener.onClick(widget)
        }

        override fun updateDrawState(ds: TextPaint) {
            super.updateDrawState(ds)

            // it's key to remove underline
            ds.isUnderlineText = false
        }
    }
}

If it is url, just inherit URLSpan and then the same as the above way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants