TextWithLinks
TextWithLinks shows a text with clickable links.
Usage
To use the TextWithLinks
composable you need to:
- Define your string resource in your XML file with an annotation tag surrounding the link text.
<string name="text_with_links">By continuing, you agree to the <annotation type="terms">Terms & Conditions</annotation> and <annotation type="privacy">Privacy Policy</annotation>.</string>
- Create a list of
TextLink
which has the annotation type value and the link which should open.val textLinkList = listOf(TextLink("terms", "https://www.terms.com"),TextLink("privacy", "https://www.privacy.com")) - Include the
TextWithLinks
composable to your screen.TextWithLinks(modifier = Modifier,stringResId = R.string.text_with_links,textLinkList = textLinkList,goToWebUrl = { url -> navigator.goToWeb(url) })