# Insets

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/graphics/Insets "View this page in Java")

<br />

```
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                                          |
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
| `const `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | [NONE](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets#NONE()) |

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

|                            ### Public properties                            |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [bottom](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets#bottom()) |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [left](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets#left())     |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [right](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets#right())   |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [top](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets#top())       |

## Constants

### NONE

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

```
const val NONE: Insets
```  

## Public functions

### add

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

```
java-static fun add(a: Insets, b: Insets): Insets
```

Add two Insets.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|---------------------------|
| `a: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The first Insets to add.  |
| `b: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The second Insets to add. |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | a + b, i. e. all insets on every side are added together. |

### equals

```
fun equals(o: Any!): Boolean
```

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

|                                     Parameters                                      |
|-------------------------------------------------------------------------------------|-------------------------------------------|
| `o: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`!` | the object to compare this instance with. |

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | true iff this object is equal`o` |

### hashCode

```
fun hashCode(): Int
```  

### max

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

```
java-static fun max(a: Insets, b: Insets): Insets
```

Returns the component-wise maximum of two Insets.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|--------------------|
| `a: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The first Insets.  |
| `b: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The second Insets. |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/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)  

```
java-static fun min(a: Insets, b: Insets): Insets
```

Returns the component-wise minimum of two Insets.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|--------------------|
| `a: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The first Insets.  |
| `b: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The second Insets. |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/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)  

```
java-static fun of(r: Rect): Insets
```

Return an Insets instance with the appropriate values.  

|                                   Parameters                                    |
|---------------------------------------------------------------------------------|---------------------------------------------|
| `r: `[Rect](https://developer.android.com/reference/android/graphics/Rect.html) | the rectangle from which to take the values |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/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)  

```
java-static fun of(left: Int, top: Int, right: Int, bottom: Int): Insets
```

Return an Insets instance with the appropriate values.  

|                                      Parameters                                       |
|---------------------------------------------------------------------------------------|------------------|
| `left: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | the left inset   |
| `top: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)    | the top inset    |
| `right: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)  | the right inset  |
| `bottom: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | the bottom inset |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|---------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/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)  

```
java-static fun subtract(a: Insets, b: Insets): Insets
```

Subtract two Insets.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|-------------------------------------------------------------|
| `a: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The minuend; the value from which`b`will be subtracted.     |
| `b: `[Insets](https://developer.android.com/reference/kotlin/androidx/core/graphics/Insets) | The subtrahend; the value which will be subtracted from`a`. |

|                                        Returns                                         |
|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [Insets](https://developer.android.com/reference/kotlin/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)
java-static fun toCompatInsets(insets: Insets): Insets
```

Return a copy of the given[android.graphics.Insets](https://developer.android.com/reference/android/graphics/Insets.html)instance, converted to be an[Insets](https://developer.android.com/reference/kotlin/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)
fun toPlatformInsets(): Insets
```

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

### toString

```
fun toString(): String
```  

## Public properties

### bottom

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

```
val bottom: Int
```  

### left

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

```
val left: Int
```  

### right

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

```
val right: Int
```  

### top

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

```
val top: Int
```