{% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SnapPositionInLayout


Describes the general positioning of a given snap item in its containing layout.

Summary

Public companion properties

SnapPositionInLayout

Aligns the center of the item with the center of the containing layout.

Cmn

Public functions

Int
Density.position(layoutSize: Int, itemSize: Int, itemIndex: Int)

Calculates an offset positioning between a container and an element within this container.

Cmn

Public companion properties

CenterToCenter

val CenterToCenterSnapPositionInLayout

Aligns the center of the item with the center of the containing layout.

Public functions

position

fun Density.position(layoutSize: Int, itemSize: Int, itemIndex: Int): Int

Calculates an offset positioning between a container and an element within this container. The offset calculation is the necessary diff that should be applied to the item offset to align the item with a position within the container. As a base line, if we wanted to align the start of the container and the start of the item, we would return 0 in this function.