Layout

interface Layout

Layouts control the positioning of a sequence of Views within a Size. They are also responsible for reporting the ideal size for a view given its contents.

Layouts automatically take control of content positioning; therefore they should be used in preference of manually monitoring a View's size.

A View's Layout will be asked to perform positioning whenever its size changes, or it becomes visible after one or more of its children has triggered a layout. A child will trigger a layout if its bounds change or if it changes visibility.

Author

Nicholas Eddy

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Gets the child within the Positionable at the given point. The default is to ignore these calls and let the caller perform their own search for the right child. But Layouts are free to return a value here if it can be done more efficiently.

Link copied to clipboard
abstract fun layout(views: Sequence<Positionable>, min: Size, current: Size, max: Size, insets: Insets = None): Size

Positions and sizes the given views and returns a size appropriate to laying out these views within the given constraints.

Link copied to clipboard
open fun preferredSize(views: Sequence<Positionable>, min: Size, current: Size, max: Size, insets: Insets = None): Size

Determines the best size to contain the views given the constraints. The default implementation relies on layout with current = max for the answer.

Link copied to clipboard
open fun requiresLayout(old: Size, new: Size): Boolean

Indicates whether a layout is needed because of the given size change to a container. This is called whenever the container's size changes.

open fun requiresLayout(child: Positionable, within: Size, old: Rectangle, new: Rectangle): Boolean

Indicates whether a layout is needed because of the given bounds change to a child within a container. This is called whenever the child's size changes.