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

SizeKt

public final class SizeKt


Summary

Public methods

static final @NonNull Size
Size(float width, float height)

Constructs a Size from the given width and height

static final @NonNull Offset
getCenter(@NonNull Size receiver)

Returns the Offset of the center of the rect from the point of 0, 0 with this Size.

static final boolean

false when this is Size.Unspecified.

static final boolean

true when this is Size.Unspecified.

static final @NonNull Size
lerp(@NonNull Size start, @NonNull Size stop, float fraction)

Linearly interpolate between two sizes

static final @NonNull Size
takeOrElse(@NonNull Size receiver, @NonNull Function0<@NonNull Size> block)

If this Size isSpecified then this is returned, otherwise block is executed and its result is returned.

static final @NonNull Size
times(double receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

static final @NonNull Size
times(float receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

static final @NonNull Size
times(int receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

static final @NonNull Rect
toRect(@NonNull Size receiver)

Convert a Size to a Rect.

Public methods

Size

public static final @NonNull Size Size(float width, float height)

Constructs a Size from the given width and height

getCenter

public static final @NonNull Offset getCenter(@NonNull Size receiver)

Returns the Offset of the center of the rect from the point of 0, 0 with this Size.

isSpecified

public static final boolean isSpecified(@NonNull Size receiver)

false when this is Size.Unspecified.

isUnspecified

public static final boolean isUnspecified(@NonNull Size receiver)

true when this is Size.Unspecified.

lerp

public static final @NonNull Size lerp(@NonNull Size start, @NonNull Size stop, float fraction)

Linearly interpolate between two sizes

The fraction argument represents position on the timeline, with 0.0 meaning that the interpolation has not started, returning start (or something equivalent to start), 1.0 meaning that the interpolation has finished, returning stop (or something equivalent to stop), and values in between meaning that the interpolation is at the relevant point on the timeline between start and stop. The interpolation can be extrapolated beyond 0.0 and 1.0, so negative values and values greater than 1.0 are valid (and can easily be generated by curves).

Values for fraction are usually obtained from an Animation, such as an AnimationController.

takeOrElse

public static final @NonNull Size takeOrElse(@NonNull Size receiver, @NonNull Function0<@NonNull Size> block)

If this Size isSpecified then this is returned, otherwise block is executed and its result is returned.

times

public static final @NonNull Size times(double receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

times

public static final @NonNull Size times(float receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

times

public static final @NonNull Size times(int receiver, @NonNull Size size)

Returns a Size with size's Size.width and Size.height multiplied by this

toRect

public static final @NonNull Rect toRect(@NonNull Size receiver)

Convert a Size to a Rect.