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

PopupPositionProvider

public interface PopupPositionProvider


Calculates the position of a Popup on screen.

Summary

Public methods

abstract @NonNull IntOffset
calculatePosition(
    @NonNull IntRect anchorBounds,
    @NonNull IntSize windowSize,
    @NonNull LayoutDirection layoutDirection,
    @NonNull IntSize popupContentSize
)

Calculates the position of a Popup on screen.

Public methods

calculatePosition

abstract @NonNull IntOffset calculatePosition(
    @NonNull IntRect anchorBounds,
    @NonNull IntSize windowSize,
    @NonNull LayoutDirection layoutDirection,
    @NonNull IntSize popupContentSize
)

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
@NonNull IntRect anchorBounds

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

@NonNull IntSize windowSize

The size of the window containing the anchor layout.

@NonNull LayoutDirection layoutDirection

The layout direction of the anchor layout.

@NonNull IntSize popupContentSize

The size of the popup's content.

Returns
@NonNull IntOffset

The window relative position where the popup should be positioned.