I have a LinearLayout, which contains several child TextViews. How can I get child views of that LinerLayout using a loop?
LinearLayout
TextViews
Get all views of a view plus its children recursively in Kotlin:
private fun View.getAllViews(): List { if (this !is ViewGroup || childCount == 0) return listOf(this) return children .toList() .flatMap { it.getAllViews() } .plus(this as View) }