Tobias Preuss
04/09/2024, 10:12 PMClickableText#style
?
ClickableText(
text = annotatedString,
style = TextStyle(
background = tapColor // <-- only change on tap
),
onClick = {
annotatedString
.getStringAnnotations(tag = tag, start = it, end = it)
.firstOrNull()
?.let { range -> onClick(range.item) }
}
)
I already tried the following without success:
• interactionSource.collectIsPressedAsState()
• pointerInput(Unit) { detectTapGestures { ... } }
• PressInteraction
: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1636513723218600?thread_ts=1636478382.181200&cid=CJLTWPH7S
• `rememberUpdatedState`: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1671519187099769Zach Klippenstein (he/him) [MOD]
04/10/2024, 12:22 AMTobias Preuss
04/10/2024, 5:11 AMAnastasia [G]
04/10/2024, 11:48 AMText
. The key is to add the LinkAnnotation
to your annotated string.Tobias Preuss
04/10/2024, 7:00 PMAnastasia [G]
04/11/2024, 12:04 PMText
and also get the TextLayoutResult
. These two steps implemented in this sample https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/[…]ation/samples/ClickableTextSample.kt;l=48?q=LongClickableText
Use the TextLayoutResult
to calculate the position where to draw the background