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

Extensions for android.view.ViewGroup

children

val ViewGroup.children: Sequence<View>

Returns a Sequence over the child views in this view group.

contains

operator fun ViewGroup.contains(view: View): Boolean

Returns true if view is found in this view group.

forEach

fun ViewGroup.forEach(action: (view: View) -> Unit): Unit

Performs the given action on each view in this view group.

forEachIndexed

fun ViewGroup.forEachIndexed(action: (index: Int, view: View) -> Unit): Unit

Performs the given action on each view in this view group, providing its sequential index.

get

operator fun ViewGroup.get(index: Int): View

Returns the view at index.

isEmpty

fun ViewGroup.isEmpty(): Boolean

Returns true if this view group contains no views.

isNotEmpty

fun ViewGroup.isNotEmpty(): Boolean

Returns true if this view group contains one or more views.

iterator

operator fun ViewGroup.iterator(): MutableIterator<View>

Returns a MutableIterator over the views in this view group.

minusAssign

operator fun ViewGroup.minusAssign(view: View): Unit

Removes view from this view group.

plusAssign

operator fun ViewGroup.plusAssign(view: View): Unit

Adds view to this view group.

size

val ViewGroup.size: Int

Returns the number of views in this view group.

updateLayoutParams

fun ViewGroup.updateLayoutParams(block: LayoutParams.() -> Unit): Unit

Executes block with the ViewGroup's layoutParams and reassigns the layoutParams with the updated version.

fun <T : LayoutParams> ViewGroup.updateLayoutParams(block: T.() -> Unit): Unit

Executes block with a typed version of the ViewGroup's layoutParams and reassigns the layoutParams with the updated version.