I am trying to get height of a view in onCreate method but I couldn\'t find any way to remove OnGlobalLayoutListener.
In Java (working):
containerLay
Referencing a lambda from inside it is not supported.
As a workaround, you might use anonymous object instead of lambda SAM-converted to Java functional interface OnGlobalLayoutListener
:
containerLayout.viewTreeObserver.addOnGlobalLayoutListener(object: OnGlobalLayoutListener {
override fun onGlobalLayout() {
// your code here. `this` should work
}
})