Skip to content

Instantly share code, notes, and snippets.

@NezSpencer
Created August 10, 2019 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NezSpencer/3dd84cde0ef3c6cd136cfb20b4bd9364 to your computer and use it in GitHub Desktop.
Save NezSpencer/3dd84cde0ef3c6cd136cfb20b4bd9364 to your computer and use it in GitHub Desktop.
import android.text.TextPaint
import android.text.style.ClickableSpan
import android.view.View
import androidx.annotation.ColorInt
class CustomClickSpan(
private val onClickListener: () -> Unit,
@ColorInt private val textColor: Int,
private val shouldUnderline: Boolean = false
) : ClickableSpan() {
override fun onClick(p0: View) = onClickListener.invoke()
override fun updateDrawState(ds: TextPaint) {
ds.isUnderlineText = shouldUnderline
ds.color = textColor
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment