Function

getFirstLinkBounds

Returns the bounds of the first link matching the predicate, or if that link spans multiple lines, returns the bounds of the first line of the link.

getFirstLinkBounds

Source set: Common
public fun SemanticsNodeInteraction.getFirstLinkBounds(
    predicate: (AnnotatedString.Range<LinkAnnotation>) -> Boolean = { true }
): Rect?

Returns the bounds of the first link matching the predicate, or if that link spans multiple lines, returns the bounds of the first line of the link.

A link in a Text composable is defined by a LinkAnnotation of the AnnotatedString.

The bounds are in the text node's coordinate system.

You can pass an offset from within the bounds to injection methods to operate them on the link, for example TouchInjectionScope.click or MouseInjectionScope.moveTo.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: