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

SnapPositionInLayout

@ExperimentalFoundationApi
public fun interface SnapPositionInLayout


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

Summary

Nested types

public static class SnapPositionInLayout.Companion

Public methods

abstract int
position(
    @NonNull Density receiver,
    int layoutSize,
    int itemSize,
    int itemIndex
)

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

Public methods

position

abstract int position(
    @NonNull Density receiver,
    int layoutSize,
    int itemSize,
    int itemIndex
)

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.