calculatePosition

abstract fun calculatePosition(density: Density, anchorBounds: IntRect, windowSize: IntSize, popupContentSize: IntSize): Int

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.

Return

The window relative position where the popup should be positioned.

Parameters

density

The density to use when calculating the position.

anchorBounds

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

windowSize

The size of the window containing the anchor layout.

popupContentSize

The size of the popup's content.