# ViewKt

Added in 1.1.0

*** ** * ** ***


```
public final class ViewKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).doOnAttach(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action when this view is attached to a window. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).doOnDetach(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action when this view is detached from a window. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).doOnLayout(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action when this view is laid out. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).doOnNextLayout(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action when this view is next laid out. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/core/view/OneShotPreDrawListener` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).doOnPreDraw(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Performs the given action when the view tree is about to be drawn. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.html` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).drawToBitmap(android.graphics.Bitmap.Config)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.Config.html config)` Return a `https://developer.android.com/reference/android/graphics/Bitmap.html` representation of this `https://developer.android.com/reference/android/view/View.html`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html>` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getAllViews()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` over this view and its descendants recursively. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/ViewParent.html>` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getAncestors()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` of the parent chain of this view by repeatedly calling `https://developer.android.com/reference/android/view/View.html#getParent()`. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginBottom()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the bottom margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginEnd()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the end margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginLeft()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the left margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginRight()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the right margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginStart()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the start margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final int` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).getMarginTop()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns the top margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).isGone()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#GONE`, false otherwise. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).isInvisible()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false otherwise. |
| `static final boolean` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).isVisible()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false otherwise. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).postDelayed(kotlin.Long,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, long delayInMillis, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Version of `https://developer.android.com/reference/android/view/View.html#postDelayed(java.lang.Runnable, long)` which re-orders the parameters, allowing the action to be placed outside of parentheses. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).postOnAnimationDelayed(kotlin.Long,kotlin.Function0)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, long delayInMillis, @https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> action )` Version of `https://developer.android.com/reference/android/view/View.html#postOnAnimationDelayed(java.lang.Runnable, long)` which re-orders the parameters, allowing the action to be placed outside of parentheses. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).setGone(kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, boolean value)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#GONE`, false otherwise. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).setInvisible(kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, boolean value)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false otherwise. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).setPadding(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/Px int size)` Sets the view's padding. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).setVisible(kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, boolean value)` Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false otherwise. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).updateLayoutParams(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block )` Executes `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).updateLayoutParams(kotlin.Function1)` with the View's layoutParams and reassigns the layoutParams with the updated version. |
| `static final void` | `<T extends https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html> https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).updateLayoutParamsTyped(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull T, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> block )` Executes `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).updateLayoutParams(kotlin.Function1)` with a typed version of the View's layoutParams and reassigns the layoutParams with the updated version. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).updatePadding(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/Px int left, @https://developer.android.com/reference/androidx/annotation/Px int top, @https://developer.android.com/reference/androidx/annotation/Px int right, @https://developer.android.com/reference/androidx/annotation/Px int bottom )` Updates this view's padding. |
| `static final void` | `https://developer.android.com/reference/androidx/core/view/ViewKt#(android.view.View).updatePaddingRelative(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.Int)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html receiver, @https://developer.android.com/reference/androidx/annotation/Px int start, @https://developer.android.com/reference/androidx/annotation/Px int top, @https://developer.android.com/reference/androidx/annotation/Px int end, @https://developer.android.com/reference/androidx/annotation/Px int bottom )` Updates this view's relative padding. |

## Public methods

### doOnAttach

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:doOnAttach) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public static final void doOnAttach(
    @NonNull View receiver,
    @NonNull Function1<@NonNull View, Unit> action
)
```

Performs the given action when this view is attached to a window. If the view is already attached to a window the action will be performed immediately, otherwise the action will be performed after the view is next attached.

The action will only be invoked once, and any listeners will then be removed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).doOnDetach(kotlin.Function1)` |   |

### doOnDetach

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:doOnDetach) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

```
public static final void doOnDetach(
    @NonNull View receiver,
    @NonNull Function1<@NonNull View, Unit> action
)
```

Performs the given action when this view is detached from a window. If the view is not attached to a window the action will be performed immediately, otherwise the action will be performed after the view is detached from its current window.

The action will only be invoked once, and any listeners will then be removed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).doOnAttach(kotlin.Function1)` |   |

### doOnLayout

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:doOnLayout) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void doOnLayout(
    @NonNull View receiver,
    @NonNull Function1<@NonNull View, Unit> action
)
```

Performs the given action when this view is laid out. If the view has been laid out and it has not requested a layout, the action will be performed straight away, otherwise the action will be performed after the view is next laid out.

The action will only be invoked once on the next layout and then removed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).doOnNextLayout(kotlin.Function1)` |   |

### doOnNextLayout

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:doOnNextLayout) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void doOnNextLayout(
    @NonNull View receiver,
    @NonNull Function1<@NonNull View, Unit> action
)
```

Performs the given action when this view is next laid out.

The action will only be invoked once on the next layout and then removed.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).doOnLayout(kotlin.Function1)` |   |

### doOnPreDraw

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:doOnPreDraw) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull OneShotPreDrawListener doOnPreDraw(
    @NonNull View receiver,
    @NonNull Function1<@NonNull View, Unit> action
)
```

Performs the given action when the view tree is about to be drawn.

The action will only be invoked once prior to the next draw and then removed.

### drawToBitmap

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:drawToBitmap) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull Bitmap drawToBitmap(@NonNull View receiver, @NonNull Bitmap.Config config)
```

Return a `https://developer.android.com/reference/android/graphics/Bitmap.html` representation of this `https://developer.android.com/reference/android/view/View.html`.

The resulting bitmap will be the same width and height as this view's current layout dimensions. This does not take into account any transformations such as scale or translation.

Note, this will use the software rendering pipeline to draw the view to the bitmap. This may result with different drawing to what is rendered on a hardware accelerated canvas (such as the device screen).

If this view has not been laid out this method will throw a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Bitmap.Config.html config` | Bitmap config of the desired bitmap. Defaults to `https://developer.android.com/reference/android/graphics/Bitmap.Config.html#ARGB_8888`. |

### getAllViews

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:allViews) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final @NonNull Sequence<@NonNull View> getAllViews(@NonNull View receiver)
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` over this view and its descendants recursively. This is a depth-first traversal similar to `https://developer.android.com/reference/android/view/View.html#findViewById(int)`. A view with no children will return a single-element sequence of itself.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.ViewGroup).descendants()` |   |

### getAncestors

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:ancestors) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/core#1.5.0)

```
public static final @NonNull Sequence<@NonNull ViewParent> getAncestors(@NonNull View receiver)
```

Returns a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.sequences/-sequence/index.html` of the parent chain of this view by repeatedly calling `https://developer.android.com/reference/android/view/View.html#getParent()`. An unattached view will return a zero-element sequence.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.ViewGroup).descendants()` |   |

### getMarginBottom

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginBottom) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginBottom(@NonNull View receiver)
```

Returns the bottom margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html` |   |

### getMarginEnd

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginEnd) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginEnd(@NonNull View receiver)
```

Returns the end margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginEnd()` |   |

### getMarginLeft

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginLeft) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginLeft(@NonNull View receiver)
```

Returns the left margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html` |   |

### getMarginRight

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginRight) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginRight(@NonNull View receiver)
```

Returns the right margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html` |   |

### getMarginStart

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginStart) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginStart(@NonNull View receiver)
```

Returns the start margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html#getMarginStart()` |   |

### getMarginTop

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:marginTop) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final int getMarginTop(@NonNull View receiver)
```

Returns the top margin if this view's `https://developer.android.com/reference/android/view/ViewGroup.LayoutParams.html` is a `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html`, otherwise 0.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html` |   |

### isGone

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isGone) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean isGone(@NonNull View receiver)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#GONE`, false otherwise.

```
if (view.isGone) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#GONE`, false to `https://developer.android.com/reference/android/view/View.html#VISIBLE`.

```
view.isGone = true
```

### isInvisible

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isInvisible) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean isInvisible(@NonNull View receiver)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false otherwise.

```
if (view.isInvisible) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false to `https://developer.android.com/reference/android/view/View.html#VISIBLE`.

```
view.isInvisible = true
```

### isVisible

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isVisible) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final boolean isVisible(@NonNull View receiver)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false otherwise.

```
if (view.isVisible) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false to `https://developer.android.com/reference/android/view/View.html#GONE`.

```
view.isVisible = true
```

### postDelayed

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:postDelayed) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull Runnable postDelayed(
    @NonNull View receiver,
    long delayInMillis,
    @NonNull Function0<Unit> action
)
```

Version of `https://developer.android.com/reference/android/view/View.html#postDelayed(java.lang.Runnable, long)` which re-orders the parameters, allowing the action to be placed outside of parentheses.

```
view.postDelayed(200) {
    doSomething()
}
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html` | the created Runnable |

### postOnAnimationDelayed

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:postOnAnimationDelayed) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final @NonNull Runnable postOnAnimationDelayed(
    @NonNull View receiver,
    long delayInMillis,
    @NonNull Function0<Unit> action
)
```

Version of `https://developer.android.com/reference/android/view/View.html#postOnAnimationDelayed(java.lang.Runnable, long)` which re-orders the parameters, allowing the action to be placed outside of parentheses.

```
view.postOnAnimationDelayed(16) {
    doSomething()
}
```

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Runnable.html` | the created Runnable |

### setGone

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isGone) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void setGone(@NonNull View receiver, boolean value)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#GONE`, false otherwise.

```
if (view.isGone) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#GONE`, false to `https://developer.android.com/reference/android/view/View.html#VISIBLE`.

```
view.isGone = true
```

### setInvisible

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isInvisible) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void setInvisible(@NonNull View receiver, boolean value)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false otherwise.

```
if (view.isInvisible) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#INVISIBLE`, false to `https://developer.android.com/reference/android/view/View.html#VISIBLE`.

```
view.isInvisible = true
```

### setPadding

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:setPadding) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void setPadding(@NonNull View receiver, @Px int size)
```

Sets the view's padding. This version of the method sets all axes to the provided size.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#setPadding(int, int, int, int)` |   |

### setVisible

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+symbol:isVisible) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void setVisible(@NonNull View receiver, boolean value)
```

Returns true when this view's visibility is `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false otherwise.

```
if (view.isVisible) {
    // Behavior...
}
```

Setting this property to true sets the visibility to `https://developer.android.com/reference/android/view/View.html#VISIBLE`, false to `https://developer.android.com/reference/android/view/View.html#GONE`.

```
view.isVisible = true
```

### updateLayoutParams

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:updateLayoutParams) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void updateLayoutParams(
    @NonNull View receiver,
    @NonNull Function1<@NonNull ViewGroup.LayoutParams, Unit> block
)
```

Executes `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).updateLayoutParams(kotlin.Function1)` with the View's layoutParams and reassigns the layoutParams with the updated version.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If no `LayoutParams` is set on the view. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#getLayoutParams()` |   |
| `https://developer.android.com/reference/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams)` |   |

### updateLayoutParamsTyped

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:updateLayoutParams)

```
public static final void <T extends ViewGroup.LayoutParams> updateLayoutParamsTyped(
    @NonNull View receiver,
    @NonNull Function1<@NonNull T, Unit> block
)
```

Executes `https://developer.android.com/reference/androidx/core/view/package-summary#(android.view.View).updateLayoutParams(kotlin.Function1)` with a typed version of the View's layoutParams and reassigns the layoutParams with the updated version.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-null-pointer-exception/index.html` | If no `LayoutParams` is set on the view. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-class-cast-exception/index.html` | If the `LayoutParams` type is not `T` or a subtype of `T`. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#getLayoutParams()` |   |
| `https://developer.android.com/reference/android/view/View.html#setLayoutParams(android.view.ViewGroup.LayoutParams)` |   |

### updatePadding

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:updatePadding) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void updatePadding(
    @NonNull View receiver,
    @Px int left,
    @Px int top,
    @Px int right,
    @Px int bottom
)
```

Updates this view's padding. This version of the method allows using named parameters to just set one or more axes.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#setPadding(int, int, int, int)` |   |

### updatePaddingRelative

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/View.kt+function:updatePaddingRelative) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public static final void updatePaddingRelative(
    @NonNull View receiver,
    @Px int start,
    @Px int top,
    @Px int end,
    @Px int bottom
)
```

Updates this view's relative padding. This version of the method allows using named parameters to just set one or more axes.

Note that this inline method references platform APIs added in API 17 and may raise runtime verification warnings on earlier platforms. See Chromium's guide to [Class Verification Failures](https://chromium.googlesource.com/chromium/src/+/HEAD/build/android/docs/class_verification_failures.md) for more information.

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#setPaddingRelative(int, int, int, int)` |   |