Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

DialogFragment: getting size change on pre-3.0 devices

MichaelMuegelMichaelMuegel US ✭✭
edited October 2012 in Xamarin.Android

DialogFragment LayoutChange event / OnLayoutChangeListener() is not available prior to Android 3.0. The only way I have come up with to detect dialog size changes as keyboard is shown is to use View sub-class OnSizeChanged() method. Is this really the only way?

This approach forces me to create an intermediate View just to capture this (since my dialog view is from a layout). It would be nice if some common "eventish" things in View were exposed as .NET events. For example, in this case create common View.SizeChanged event.


  • MichaelMuegelMichaelMuegel US ✭✭
    edited October 2012

    I stumbled on View.ViewTreeObserver.GlobalLayout event. This can be used to synthesize a size change event by keeping track of previous sizes. This is available all the way back to API Level 1.

  • Another benefit of GlobalLayout is that, unlike OnSizeChange(), all layout will have finished and sizes can be accurately inspected.

Sign In or Register to comment.