# Kotlin recipes for Android (I): OnGlobalLayoutListener

DevFeed: [Kotlin recipes for Android (I): OnGlobalLayoutListener](<https://devfeed.tech/articles/kotlin-recipes-for-android-i-ongloballayoutlistener-27187.md>)

Original publisher: [Read original article](<https://antonioleiva.com/kotlin-ongloballayoutlistener>)

Published: 2016-03-15T00:00:00Z

Content type: tutorial

Language: en

Sources: [Antonio Leiva](<https://devfeed.tech/sources/antonio-leiva.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Android](<https://devfeed.tech/topics/android.md>), [interoperability](<https://devfeed.tech/topics/interoperability.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [interoperability](<https://devfeed.tech/tags/interoperability.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>)

## AI overview

A Kotlin tutorial for Android explains how to use OnGlobalLayoutListener to run work after a View has been measured, while avoiding listener-related leaks. It proposes an extension function that adds and removes the listener automatically, then improves it with a generic View extension and a lambda that can access the view's properties and methods.

## Source excerpt

Everything Android, Kotlin and other random topics