Instantly share code, notes, and snippets.

Embed
What would you like to do?
Logs all subviews of a ViewGroup recursively.
private fun logView(viewGroup: ViewGroup) {
for (i in 0 until viewGroup.childCount) {
val child = viewGroup.getChildAt(i)
Log.d(child.toString() + " ID: ${child.id} TAG: ${child.tag}")
if (child is ViewGroup) {
logView(child)
}
}
}
/** Example for com.google.android.gms.maps.MapView as of Google Play Services version 11.4.2:
11-06 14:27:20.276 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.FrameLayout{dd70f1a V.E...... ......I. 0,0-0,0} ID: -1 TAG: GoogleMapView
11-06 14:27:20.276 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): com.google.maps.api.android.lib6.gmm6.api.x{3478a4b VFED..C.. ......I. 0,0-0,0} ID: -1 TAG: null
11-06 14:27:20.277 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.RelativeLayout{29aec28 V.E...... ......I. 0,0-0,0} ID: -1 TAG: null
11-06 14:27:20.277 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{edaed41 V.ED..... ......ID 0,0-0,0} ID: -1 TAG: GoogleWatermark
11-06 14:27:20.277 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.TextView{8c702e6 G.ED..... ......ID 0,0-0,0} ID: -1 TAG: GoogleCopyrights
11-06 14:27:20.278 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.RelativeLayout{3828027 V.E...... ......I. 0,0-0,0} ID: -1 TAG: null
11-06 14:27:20.278 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{6c6a2d4 G.ED..... ......ID 0,0-0,0 #2} ID: 2 TAG: GoogleMapMyLocationButton
11-06 14:27:20.278 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.RelativeLayout{c281c7d V.E...... ......I. 0,0-0,0 #3} ID: 3 TAG: null
11-06 14:27:20.278 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): com.google.maps.api.android.lib6.impl.cb{a3f883c G.ED..C.. ......I. 0,0-0,0} ID: -1 TAG: null
11-06 14:27:20.279 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.LinearLayout{b706772 G.E...... ......I. 0,0-0,0 #1} ID: 1 TAG: null
11-06 14:27:20.279 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{28cf7c3 VFED..C.. ......I. 0,0-0,0} ID: -1 TAG: GoogleMapZoomInButton
11-06 14:27:20.279 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{d551840 VFED..C.. ......I. 0,0-0,0} ID: -1 TAG: GoogleMapZoomOutButton
11-06 14:27:20.280 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.LinearLayout{c1f0379 G.E...... ......I. 0,0-0,0 #4} ID: 4 TAG: GoogleMapToolbar
11-06 14:27:20.280 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{4d988be VFED..C.. ......ID 0,0-0,0} ID: -1 TAG: GoogleMapDirectionsButton
11-06 14:27:20.280 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): android.widget.ImageView{93d4d1f VFED..C.. ......ID 0,0-0,0} ID: -1 TAG: GoogleMapOpenGmmButton
11-06 14:27:20.281 22669-22669/de.elegyd.test D/(FragmentMap.kt:137): com.google.maps.api.android.lib6.impl.al{193786c IFED..C.. ......I. 0,0-0,0 #5} ID: 5 TAG: GoogleMapCompass
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment