LinkAnnotation.Clickable
-
Cmn
class LinkAnnotation.Clickable : LinkAnnotation
| kotlin.Any | ||
| ↳ | androidx.compose.ui.text.LinkAnnotation | |
| ↳ | androidx.compose.ui.text.LinkAnnotation.Clickable |
An annotation that contains a clickable marked with tag. When clicking on the text to which this annotation is attached, the app will trigger a linkInteractionListener listener.
| See also | |
|---|---|
LinkAnnotation |
Summary
Public constructors |
|
|---|---|
Clickable( |
Cmn
|
Public functions |
||
|---|---|---|
LinkAnnotation.Clickable |
copy(Returns a copy of this |
Cmn
|
open operator Boolean |
Cmn
|
|
open Int |
hashCode() |
Cmn
|
open String |
toString() |
Cmn
|
Public properties |
||
|---|---|---|
open LinkInteractionListener? |
Interaction listener triggered when user interacts with this link. |
Cmn
|
open TextLinkStyles? |
Style configuration for this link in different states. |
Cmn
|
String |
Cmn
|
Public constructors
Clickable
Clickable(
tag: String,
styles: TextLinkStyles? = null,
linkInteractionListener: LinkInteractionListener?
)
Public functions
copy
fun copy(
tag: String = this.tag,
styles: TextLinkStyles? = this.styles,
linkInteractionListener: LinkInteractionListener? = this.linkInteractionListener
): LinkAnnotation.Clickable
Returns a copy of this Clickable, optionally overriding some of the values.
Public properties
linkInteractionListener
open val linkInteractionListener: LinkInteractionListener?
Interaction listener triggered when user interacts with this link.
import androidx.compose.foundation.text.BasicText import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextLinkStyles import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.withLink import androidx.compose.ui.unit.sp // Display a link in the text and log metrics whenever user clicks on it. In that case we handle // the link using openUri method of the LocalUriHandler val uriHandler = LocalUriHandler.current BasicText( buildAnnotatedString { append("Build better apps faster with ") val link = LinkAnnotation.Url( "https://developer.android.com/jetpack/compose", TextLinkStyles(SpanStyle(color = Color.Blue)), ) { val url = (it as LinkAnnotation.Url).url // log some metrics uriHandler.openUri(url) } withLink(link) { append("Jetpack Compose") } } )
styles
open val styles: TextLinkStyles?
Style configuration for this link in different states.
import androidx.compose.foundation.text.BasicText import androidx.compose.ui.graphics.Color import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextLinkStyles import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.withLink import androidx.compose.ui.unit.sp // Display a link in the text that gets an underline when hovered BasicText( buildAnnotatedString { append("Build better apps faster with ") val link = LinkAnnotation.Url( "https://developer.android.com/jetpack/compose", TextLinkStyles( style = SpanStyle(color = Color.Blue), hoveredStyle = SpanStyle(textDecoration = TextDecoration.Underline), ), ) withLink(link) { append("Jetpack Compose") } } )