spanner icon indicating copy to clipboard operation
spanner copied to clipboard

Click without underline support

Open neworld opened this issue 6 years ago • 1 comments

spanner.append("google", url("http://www.google.lt"), noUnderline())

neworld avatar Oct 12 '17 14:10 neworld

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.

notHide avatar Oct 28 '17 11:10 notHide