Function

percentOffset

Creates an Offset relative to the size of the node we're interacting with.

percentOffset

Source set: Common
@Deprecated(
    message = "Replaced by TouchInjectionScope. Use `performTouchInput` instead of `performGesture`"
)
public fun GestureScope.percentOffset(
    /*@FloatRange(from = -1.0, to = 1.0)*/
    x: Float = 0f,
    /*@FloatRange(from = -1.0, to = 1.0)*/
    y: Float = 0f,
): Offset

Creates an Offset relative to the size of the node we're interacting with. x and y are fractions of the width and height, between -1 and 1. Note that percentOffset(1f, 1f) != bottomRight, see right and bottom.

For example: percentOffset(.5f, .5f) is the same as the center; centerLeft + percentOffset(.1f, 0f) is a point 10% inward from the middle of the left edge; and bottomRight - percentOffset(.2f, .1f) is a point 20% to the left and 10% to the top of the bottom right corner.

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: