core-ktx / androidx.view / android.view.View

Extensions for android.view.View

doOnLayout

fun View.doOnLayout(action: (view: View) -> Unit): Unit

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.

doOnNextLayout

fun View.doOnNextLayout(action: (view: View) -> Unit): Unit

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

doOnPreDraw

fun View.doOnPreDraw(action: (view: View) -> Unit): Unit

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

isGone

var View.isGone: Boolean

Returns true when this view's visibility is View.GONE, false otherwise.

isInvisible

var View.isInvisible: Boolean

Returns true when this view's visibility is View.INVISIBLE, false otherwise.

isVisible

var View.isVisible: Boolean

Returns true when this view's visibility is View.VISIBLE, false otherwise.

postDelayed

fun View.postDelayed(delayInMillis: Long, action: () -> Unit): Runnable

Version of View.postDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

postOnAnimationDelayed

fun View.postOnAnimationDelayed(delayInMillis: Long, action: () -> Unit): Runnable

Version of View.postOnAnimationDelayed which re-orders the parameters, allowing the action to be placed outside of parentheses.

setPadding

fun View.setPadding(size: Int): Unit

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

toBitmap

fun View.toBitmap(config: Config = Bitmap.Config.ARGB_8888): Bitmap

Return a Bitmap representation of this View.

updatePadding

fun View.updatePadding(left: Int = paddingLeft, top: Int = paddingTop, right: Int = paddingRight, bottom: Int = paddingBottom): Unit

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

updatePaddingRelative

fun View.updatePaddingRelative(start: Int = paddingStart, top: Int = paddingTop, end: Int = paddingEnd, bottom: Int = paddingBottom): Unit

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