Insets

Added in 1.2.0

public final class 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

Constants

static final @NonNull Insets

Public fields

final int
final int
final int
final int

Public methods

static @NonNull Insets

Add two Insets.

boolean

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

int
static @NonNull Insets

Returns the component-wise maximum of two Insets.

static @NonNull Insets

Returns the component-wise minimum of two Insets.

static @NonNull Insets

Return an Insets instance with the appropriate values.

static @NonNull Insets
of(int left, int top, int right, int bottom)

Return an Insets instance with the appropriate values.

static @NonNull Insets

Subtract two Insets.

static @NonNull Insets

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

@NonNull Insets

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

@NonNull String

Constants

NONE

Added in 1.2.0
public static final @NonNull Insets NONE

Public fields

bottom

Added in 1.2.0
public final int bottom

left

Added in 1.2.0
public final int left

right

Added in 1.2.0
public final int right

top

Added in 1.2.0
public final int top

Public methods

add

Added in 1.5.0
public static @NonNull Insets add(@NonNull Insets a, @NonNull Insets b)

Add two Insets.

Parameters
@NonNull Insets a

The first Insets to add.

@NonNull Insets b

The second Insets to add.

Returns
@NonNull Insets

a + b, i. e. all insets on every side are added together.

equals

public boolean equals(Object o)

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

Parameters
Object o

the object to compare this instance with.

Returns
boolean

true iff this object is equal o

hashCode

public int hashCode()

max

Added in 1.5.0
public static @NonNull Insets max(@NonNull Insets a, @NonNull Insets b)

Returns the component-wise maximum of two Insets.

Parameters
@NonNull Insets a

The first Insets.

@NonNull Insets b

The second Insets.

Returns
@NonNull Insets

an Insets instance where the inset on each side is the larger of the insets on that side from a and b.

min

Added in 1.5.0
public static @NonNull Insets min(@NonNull Insets a, @NonNull Insets b)

Returns the component-wise minimum of two Insets.

Parameters
@NonNull Insets a

The first Insets.

@NonNull Insets b

The second Insets.

Returns
@NonNull Insets

an Insets instance where the inset on each side is the smaller of the insets on that side from a and b.

of

Added in 1.2.0
public static @NonNull Insets of(@NonNull Rect r)

Return an Insets instance with the appropriate values.

Parameters
@NonNull Rect r

the rectangle from which to take the values

Returns
@NonNull Insets

an Insets instance with the appropriate values

of

Added in 1.2.0
public static @NonNull Insets of(int left, int top, int right, int bottom)

Return an Insets instance with the appropriate values.

Parameters
int left

the left inset

int top

the top inset

int right

the right inset

int bottom

the bottom inset

Returns
@NonNull Insets

Insets instance with the appropriate values

subtract

Added in 1.5.0
public static @NonNull Insets subtract(@NonNull Insets a, @NonNull Insets b)

Subtract two Insets.

Parameters
@NonNull Insets a

The minuend; the value from which b will be subtracted.

@NonNull Insets b

The subtrahend; the value which will be subtracted from a.

Returns
@NonNull Insets

a - b, i. e. all insets on every side are subtracted from each other.

toCompatInsets

Added in 1.3.0
@RequiresApi(api = 29)
public static @NonNull Insets toCompatInsets(@NonNull Insets insets)

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

toPlatformInsets

Added in 1.3.0
@RequiresApi(value = 29)
public @NonNull Insets toPlatformInsets()

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

toString

public @NonNull String toString()