Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
fun getAllChildren(v: View, recursive: Boolean, ignoredElements: List<View>): ArrayList<View> {
if (v !is ViewGroup || v.childCount == 0) {
val r = ArrayList<View>()
return r
} else {
val list = ArrayList<View>()
val children = v.childCount
for (i in 0 until children) {
val child = v.getChildAt(i)
if (!ignoredElements.contains(child)) {
if (recursive) {
list.addAll(getAllChildren(child, recursive, ignoredElements))
} else {
return list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.