Xamarin C# Android getting height 0 and cant remove GlobalLayoutListener event


You can height or width 0 when trying to access during on Create. This is because the lifecycle of the view hasnt been completed yet.

You need to wait until the view layout has been completed.

public void MyMethodThatNeedsHeight()
//do something

Most articles mention use of AddOnGlobalLayoutListener but it didnt seem possible to remove the event handler, which didnt work for me (for more info see https://forums.xamarin.com/discussion/19022/how-do-i-get-the-height-of-a-linearlayout-oncreate-method-in-an-activity)