Skip to main content

Clickable link text for Android TextView — Kotlin Extension

Published 1 min readMarkdown
Clickable link text for Android TextView — Kotlin Extension

Recently I have had to create UI that required user tappable/clickable text in the same text view. I know this is kind of unusual as the touch target for the view will likely be smaller compared to a button with no outline style. However, I wanted to share a quick Kotlin extension function that is dynamic and well tested.

Android TextView where “Register Now” is a tappable link with a callback.

Here is an example usage for generating clickable link within the same TextView

So, if your project requires something like this take a look at the following extension function for android.widget.TextView.

You should be able to easily convert this to Java if needed. Let me know if you find this useful. Cheers ✌️

About the author

  • Passionate Android developer and curious tinkerer!🤖

No comments yet. Be the first to comment.