Created
December 2, 2019 16:33
-
-
Save nikhilpanju/7d6a1ba871e8ecb0aab6ee4c7ca3943c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <T : View> T.doOnGlobalLayout(crossinline action: () -> Unit) { | |
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { | |
override fun onGlobalLayout() { | |
viewTreeObserver.removeOnGlobalLayoutListener(this) | |
action() | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment