# Insets

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/graphics/Insets.java+class:androidx.core.graphics.Insets) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

*** ** * ** ***


```
public final class Insets
```

<br />

*** ** * ** ***

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 @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#NONE()` |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/core/graphics/Insets#bottom()` |
| `final int` | `https://developer.android.com/reference/androidx/core/graphics/Insets#left()` |
| `final int` | `https://developer.android.com/reference/androidx/core/graphics/Insets#right()` |
| `final int` | `https://developer.android.com/reference/androidx/core/graphics/Insets#top()` |

| ### Public methods |
|---|---|
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#add(androidx.core.graphics.Insets,androidx.core.graphics.Insets)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b)` Add two Insets. |
| `boolean` | `https://developer.android.com/reference/androidx/core/graphics/Insets#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html o)` Two Insets instances are equal if they belong to the same class and their fields are pairwise equal. |
| `int` | `https://developer.android.com/reference/androidx/core/graphics/Insets#hashCode()()` |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#max(androidx.core.graphics.Insets,androidx.core.graphics.Insets)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b)` Returns the component-wise maximum of two Insets. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#min(androidx.core.graphics.Insets,androidx.core.graphics.Insets)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b)` Returns the component-wise minimum of two Insets. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#of(android.graphics.Rect)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html r)` Return an Insets instance with the appropriate values. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#of(int,int,int,int)(int left, int top, int right, int bottom)` Return an Insets instance with the appropriate values. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `https://developer.android.com/reference/androidx/core/graphics/Insets#subtract(androidx.core.graphics.Insets,androidx.core.graphics.Insets)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b)` Subtract two Insets. |
| `static @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(api = 29) https://developer.android.com/reference/androidx/core/graphics/Insets#toCompatInsets(android.graphics.Insets)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Insets.html insets)` Return a copy of the given `https://developer.android.com/reference/android/graphics/Insets.html` instance, converted to be an `https://developer.android.com/reference/androidx/core/graphics/Insets` instance from AndroidX. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Insets.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 29) https://developer.android.com/reference/androidx/core/graphics/Insets#toPlatformInsets()()` Return a copy this instance, converted to be an `https://developer.android.com/reference/android/graphics/Insets.html` instance from the platform. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/core/graphics/Insets#toString()()` |

## Constants

### NONE

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public static final @NonNull Insets NONE
```

## Public fields

### bottom

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public final int bottom
```

### left

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public final int left
```

### right

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public final int right
```

### top

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public final int top
```

## Public methods

### add

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull Insets add(@NonNull Insets a, @NonNull Insets b)
```

Add two Insets.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a` | The first Insets to add. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b` | The second Insets to add. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/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 |
|---|---|
| `https://developer.android.com/reference/java/lang/Object.html 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](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull Insets max(@NonNull Insets a, @NonNull Insets b)
```

Returns the component-wise maximum of two Insets.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a` | The first Insets. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b` | The second Insets. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/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](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull Insets min(@NonNull Insets a, @NonNull Insets b)
```

Returns the component-wise minimum of two Insets.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a` | The first Insets. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b` | The second Insets. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/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](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public static @NonNull Insets of(@NonNull Rect r)
```

Return an Insets instance with the appropriate values.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/graphics/Rect.html r` | the rectangle from which to take the values |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | an Insets instance with the appropriate values |

### of

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | Insets instance with the appropriate values |

### subtract

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static @NonNull Insets subtract(@NonNull Insets a, @NonNull Insets b)
```

Subtract two Insets.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets a` | The minuend; the value from which `b` will be subtracted. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets b` | The subtrahend; the value which will be subtracted from `a`. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/graphics/Insets` | a - b, i. e. all insets on every side are subtracted from each other. |

### toCompatInsets

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)

```
@RequiresApi(api = 29)
public static @NonNull Insets toCompatInsets(@NonNull Insets insets)
```

Return a copy of the given `https://developer.android.com/reference/android/graphics/Insets.html` instance, converted to be an `https://developer.android.com/reference/androidx/core/graphics/Insets` instance from AndroidX.

### toPlatformInsets

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/core#1.3.0)

```
@RequiresApi(value = 29)
public @NonNull Insets toPlatformInsets()
```

Return a copy this instance, converted to be an `https://developer.android.com/reference/android/graphics/Insets.html` instance from the platform.

### toString

```
public @NonNull String toString()
```