TextLink
TextLink is not a view, it is an extension function over TextView which allows you to set links inside a TextView.
TextView.setTextLinkList(textLinkList: List<TextLink>, goToWebUrl: (String) -> Unit)Usage
To set a link in a TextView with text you need to:
- Define your string resource in your XML file with an annotation tag surrounding the link text.
<string name="text_with_links">This is an example <annotation type="myLinkValue">with this link</annotation>.</string>
- Create a list of
TextLinkwhich has the annotation type value and the link which should open.val textLinkList = listOf(TextLink("myLinkValue", "https://www.example.com")) - Set the string to the
TextView, in code or layout. - Call
setTextLinkListover theTextViewwith the list ofTextLinkand a function reference to navigate to aWebView.textView.setTextLinkList(it.textLinkList, navigator::goToWeb)