PopupPositionProviderAtPosition



A PopupPositionProvider that positions the popup at the given offsets and alignment.

Summary

Public constructors

PopupPositionProviderAtPosition(
    positionPx: Offset,
    isRelativeToAnchor: Boolean,
    offsetPx: Offset,
    alignment: Alignment,
    windowMarginPx: Int
)
android

Public functions

open IntOffset
calculatePosition(
    anchorBounds: IntRect,
    windowSize: IntSize,
    layoutDirection: LayoutDirection,
    popupContentSize: IntSize
)

Calculates the position of a Popup on screen.

android

Public properties

Alignment

The alignment of the popup relative to desired position.

android
Boolean

Whether positionPx is relative to the anchor bounds passed to calculatePosition.

android
Offset

Extra offset to be added to the position of the popup, in pixels.

android
Offset

The offset of the popup's location, in pixels.

android
Int

Defines the area within the window that limits the placement of the popup, in pixels.

android

Public constructors

PopupPositionProviderAtPosition

PopupPositionProviderAtPosition(
    positionPx: Offset,
    isRelativeToAnchor: Boolean,
    offsetPx: Offset,
    alignment: Alignment = Alignment.BottomEnd,
    windowMarginPx: Int
)
Parameters
positionPx: Offset

The offset of the popup's location, in pixels.

isRelativeToAnchor: Boolean

Whether positionPx is relative to the anchor bounds passed to calculatePosition. If false, it is relative to the window.

offsetPx: Offset

Extra offset to be added to the position of the popup, in pixels.

alignment: Alignment = Alignment.BottomEnd

The alignment of the popup relative to desired position.

windowMarginPx: Int

Defines the area within the window that limits the placement of the popup, in pixels.

Public functions

calculatePosition

open fun calculatePosition(
    anchorBounds: IntRect,
    windowSize: IntSize,
    layoutDirection: LayoutDirection,
    popupContentSize: IntSize
): IntOffset

Calculates the position of a Popup on screen.

The window size is useful in cases where the popup is meant to be positioned next to its anchor instead of inside of it. The size can be used to calculate available space around the parent to find a spot with enough clearance (e.g. when implementing a dropdown). Note that positioning the popup outside of the window bounds might prevent it from being visible.

Parameters
anchorBounds: IntRect

The window relative bounds of the layout which this popup is anchored to.

windowSize: IntSize

The size of the window containing the anchor layout.

layoutDirection: LayoutDirection

The layout direction of the anchor layout.

popupContentSize: IntSize

The size of the popup's content.

Returns
IntOffset

The window relative position where the popup should be positioned.

Public properties

alignment

val alignmentAlignment

The alignment of the popup relative to desired position.

isRelativeToAnchor

val isRelativeToAnchorBoolean

Whether positionPx is relative to the anchor bounds passed to calculatePosition. If false, it is relative to the window.

offsetPx

val offsetPxOffset

Extra offset to be added to the position of the popup, in pixels.

positionPx

val positionPxOffset

The offset of the popup's location, in pixels.

windowMarginPx

val windowMarginPxInt

Defines the area within the window that limits the placement of the popup, in pixels.