PopupPositionProvider
@Immutable interface PopupPositionProvider
androidx.compose.ui.window.PopupPositionProvider |
Calculates the position of a Popup on screen.
Summary
Public methods | |
---|---|
abstract IntOffset |
calculatePosition(parentGlobalBounds: IntBounds, windowGlobalBounds: IntBounds, layoutDirection: LayoutDirection, popupContentSize: IntSize) Calculates the position of a Popup on screen. |
Public methods
calculatePosition
abstract fun calculatePosition(
parentGlobalBounds: IntBounds,
windowGlobalBounds: IntBounds,
layoutDirection: LayoutDirection,
popupContentSize: IntSize
): IntOffset
Calculates the position of a Popup on screen.
Window bounds are useful in cases where the popup is meant to be posited next to its parent instead of inside of it. The window bounds can be used to detect available space around the parent to find a spot with enough clearance (e.g. when implementing dropdown). Positioning the popup outside of the window bounds might prevent it from being visible.
The window relative position of the parent can be calculated from windowGlobalBounds and parentGlobalBounds.
Parameters | |
---|---|
parentGlobalBounds: IntBounds | The screen relative global bounds of the parent layout. |
windowGlobalBounds: IntBounds | The screen relative global bounds of the window that contains the parent. These are the visible bounds without any overlapping system insets. |
layoutDirection: LayoutDirection | The layout direction of the parent layout. |
popupContentSize: IntSize | The size of the popup's content. |
Return | |
---|---|
The screen relative global position where the popup should be placed to. |