descendants

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

This performs a depth-first traversal. A view with no children will return a zero-element sequence.

For example, to efficiently filter views within the hierarchy using a predicate:

fun ViewGroup.findViewTreeIterator(predicate: (View) -> Boolean): Sequence<View> {
return sequenceOf(this)
.plus(descendantsTree)
.filter { predicate(it) }
}

See also