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

DpSize

value public final class DpSize


A two-dimensional Size using Dp for units

Summary

Nested types

public static class DpSize.Companion

Public methods

final @NonNull Dp
final @NonNull Dp
final @NonNull DpSize
copy(@NonNull Dp width, @NonNull Dp height)

Returns a copy of this DpSize instance optionally overriding the width or height parameter

final @NonNull DpSize
div(float other)
final @NonNull DpSize
div(int other)
final @NonNull Dp

The vertical aspect of the Size in Dp

final @NonNull Dp

The horizontal aspect of the Size in Dp

final @NonNull DpSize

Subtract a DpSize from another one.

final @NonNull DpSize

Add a DpSize to another one.

final @NonNull DpSize
times(float other)
final @NonNull DpSize
times(int other)
@NonNull String

Extension functions

final @NonNull DpOffset

Returns the DpOffset of the center of the rect from the point of 0, 0 with this DpSize.

final boolean

false when this is DpSize.Unspecified.

final boolean

true when this is DpSize.Unspecified.

final @NonNull DpSize
DpKt.takeOrElse(
    @NonNull DpSize receiver,
    @NonNull Function0<@NonNull DpSize> block
)

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

Public methods

component1

public final @NonNull Dp component1()

component2

public final @NonNull Dp component2()

copy

public final @NonNull DpSize copy(@NonNull Dp width, @NonNull Dp height)

Returns a copy of this DpSize instance optionally overriding the width or height parameter

div

public final @NonNull DpSize div(float other)

div

public final @NonNull DpSize div(int other)

getHeight

public final @NonNull Dp getHeight()

The vertical aspect of the Size in Dp

getWidth

public final @NonNull Dp getWidth()

The horizontal aspect of the Size in Dp

minus

public final @NonNull DpSize minus(@NonNull DpSize other)

Subtract a DpSize from another one.

plus

public final @NonNull DpSize plus(@NonNull DpSize other)

Add a DpSize to another one.

times

public final @NonNull DpSize times(float other)

times

public final @NonNull DpSize times(int other)

toString

public @NonNull String toString()

Extension functions

DpKt.getCenter

public final @NonNull DpOffset DpKt.getCenter(@NonNull DpSize receiver)

Returns the DpOffset of the center of the rect from the point of 0, 0 with this DpSize.

DpKt.isSpecified

public final boolean DpKt.isSpecified(@NonNull DpSize receiver)

false when this is DpSize.Unspecified.

DpKt.isUnspecified

public final boolean DpKt.isUnspecified(@NonNull DpSize receiver)

true when this is DpSize.Unspecified.

DpKt.takeOrElse

public final @NonNull DpSize DpKt.takeOrElse(
    @NonNull DpSize receiver,
    @NonNull Function0<@NonNull DpSize> block
)

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