SnapPosition
Interface
Common
interface SnapPosition
Describes the snapping positioning (i.e. final positioning after snapping animation finishes) of a given snap item in its containing layout.
Functions
fun position(
layoutSize: Int,
itemSize: Int,
beforeContentPadding: Int,
afterContentPadding: Int,
itemIndex: Int,
itemCount: Int,
): Int
Calculates the snap position where items will be aligned to in a snapping container. For
instance, if SnapPosition.Center
is used, once the snapping finishes the center of one of
the items in the snapping container will be aligned exactly to the center of the snapping
container, that is because the value returned by position
was calculated as such a way that
when one applies it to the item's current offset it will generate that final positioning.
The reference point is with respect to the start of the layout (including the content padding)
Parameters
layoutSize | The main axis layout size within which an item can be positioned. |
itemSize | The main axis size for the item being positioned within this snapping layout. |
beforeContentPadding | The content padding in pixels applied before this Layout's content. |
afterContentPadding | The content padding in pixels applied after this Layout's content. |
itemIndex | The index of the item being positioned. |
itemCount | The total amount of items in the snapping container. |
Returns
The offset of the snap position where items will be aligned to in a snapping container. |