Android 12 Developer Preview is here! Try it out, and give us your feedback!

Insets

class Insets
kotlin.Any
   ↳ androidx.core.graphics.Insets

An Insets instance holds four integer offsets which describe changes to the four edges of a Rectangle. By convention, positive values move edges towards the centre of the rectangle.

Insets are immutable so may be treated as values.

Summary

Public methods
static Insets
add(@NonNull a: Insets, @NonNull b: Insets)

Add two Insets.

Boolean
equals(other: Any?)

Two Insets instances are equal if they belong to the same class and their fields are pairwise equal.

Int

static Insets
max(@NonNull a: Insets, @NonNull b: Insets)

Returns the component-wise maximum of two Insets.

static Insets
min(@NonNull a: Insets, @NonNull b: Insets)

Returns the component-wise minimum of two Insets.

static Insets
of(left: Int, top: Int, right: Int, bottom: Int)

Return an Insets instance with the appropriate values.

static Insets
of(@NonNull r: Rect)

Return an Insets instance with the appropriate values.

static Insets
subtract(@NonNull a: Insets, @NonNull b: Insets)

Subtract two Insets.

static Insets
toCompatInsets(@NonNull insets: Insets)

Return a copy of the given android.graphics.Insets instance, converted to be an Insets instance from AndroidX.

Insets

Return a copy this instance, converted to be an android.graphics.Insets instance from the platform.

String

Properties
static Insets

Int

Int

Int

Int

Public methods

add

@NonNull static fun add(
    @NonNull a: Insets,
    @NonNull b: Insets
): Insets

Add two Insets.

Parameters
a Insets: The first Insets to add.
b Insets: The second Insets to add.
Return
Insets a + b, i. e. all insets on every side are added together.

equals

fun equals(other: Any?): Boolean

Two Insets instances are equal if they belong to the same class and their fields are pairwise equal.

Parameters
o the object to compare this instance with.
Return
Boolean true iff this object is equal o

hashCode

fun hashCode(): Int

max

@NonNull static fun max(
    @NonNull a: Insets,
    @NonNull b: Insets
): Insets

Returns the component-wise maximum of two Insets.

Parameters
a Insets: The first Insets.
b Insets: The second Insets.
Return
Insets an Insets instance where the inset on each side is the larger of the insets on that side from a and b.

min

@NonNull static fun min(
    @NonNull a: Insets,
    @NonNull b: Insets
): Insets

Returns the component-wise minimum of two Insets.

Parameters
a Insets: The first Insets.
b Insets: The second Insets.
Return
Insets an Insets instance where the inset on each side is the smaller of the insets on that side from a and b.

of

@NonNull static fun of(
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
): Insets

Return an Insets instance with the appropriate values.

Parameters
left Int: the left inset