spanner
spanner copied to clipboard
Click without underline support
spanner.append("google", url("http://www.google.lt"), noUnderline())
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.