Created
August 10, 2019 15:21
-
-
Save NezSpencer/3dd84cde0ef3c6cd136cfb20b4bd9364 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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