diff --git a/Xamarin.Forms.Platform.Android/Platform.cs b/Xamarin.Forms.Platform.Android/Platform.cs index 143fb72eb3a..58a1a7830b9 100644 --- a/Xamarin.Forms.Platform.Android/Platform.cs +++ b/Xamarin.Forms.Platform.Android/Platform.cs @@ -1315,16 +1315,6 @@ protected override void Dispose(bool disposing) bool ILayoutChanges.HasLayoutOccurred => _hasLayoutOccurred; - protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) - { - if (Element is Layout layout) - { - layout.ResolveLayoutChanges(); - } - - base.OnMeasure(widthMeasureSpec, heightMeasureSpec); - } - protected override void OnLayout(bool changed, int left, int top, int right, int bottom) { base.OnLayout(changed, left, top, right, bottom); diff --git a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs index ae9c18823c3..0c422224571 100644 --- a/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.Android/VisualElementRenderer.cs @@ -505,5 +505,15 @@ internal virtual void SendVisualElementInitialized(VisualElement element, AView void IVisualElementRenderer.SetLabelFor(int? id) => ViewCompat.SetLabelFor(this, id ?? ViewCompat.GetLabelFor(this)); + + protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) + { + if (Element is Layout layout) + { + layout.ResolveLayoutChanges(); + } + + base.OnMeasure(widthMeasureSpec, heightMeasureSpec); + } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.UAP/LayoutRenderer.cs b/Xamarin.Forms.Platform.UAP/LayoutRenderer.cs index ef4509be5d5..b0240ce948b 100644 --- a/Xamarin.Forms.Platform.UAP/LayoutRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/LayoutRenderer.cs @@ -80,11 +80,5 @@ void UpdateClipToBounds() Clip = new RectangleGeometry { Rect = new WRect(0, 0, ActualWidth, ActualHeight) }; } } - - protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Size availableSize) - { - Element?.ResolveLayoutChanges(); - return base.MeasureOverride(availableSize); - } } } \ No newline at end of file diff --git a/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs b/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs index 85f28f777df..7d5232f9d2a 100644 --- a/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.UAP/VisualElementRenderer.cs @@ -294,6 +294,11 @@ protected override Windows.Foundation.Size MeasureOverride(Windows.Foundation.Si if (Element == null || availableSize.Width * availableSize.Height == 0) return new Windows.Foundation.Size(0, 0); + if (Element is Layout layout) + { + layout.ResolveLayoutChanges(); + } + Element.IsInNativeLayout = true; for (var i = 0; i < ElementController.LogicalChildren.Count; i++) diff --git a/Xamarin.Forms.Platform.iOS/Platform.cs b/Xamarin.Forms.Platform.iOS/Platform.cs index fb04e9f3156..35d70d8c931 100644 --- a/Xamarin.Forms.Platform.iOS/Platform.cs +++ b/Xamarin.Forms.Platform.iOS/Platform.cs @@ -586,26 +586,6 @@ public override UIView HitTest(CGPoint point, UIEvent uievent) return result; } - - void ResolveLayoutChanges() - { - if (Element is Layout layout) - { - layout.ResolveLayoutChanges(); - } - } - - public override void LayoutSubviews() - { - ResolveLayoutChanges(); - base.LayoutSubviews(); - } - - public override CGSize SizeThatFits(CGSize size) - { - ResolveLayoutChanges(); - return base.SizeThatFits(size); - } } internal static string ResolveMsAppDataUri(Uri uri) diff --git a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs index f46911fb939..4d6ed225fb5 100644 --- a/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs +++ b/Xamarin.Forms.Platform.iOS/VisualElementRenderer.cs @@ -312,13 +312,25 @@ public void SetElement(TElement element) } #if __MOBILE__ + + void ResolveLayoutChanges() + { + if (Element is Layout layout) + { + layout.ResolveLayoutChanges(); + } + } + public override SizeF SizeThatFits(SizeF size) { + ResolveLayoutChanges(); return new SizeF(0, 0); } public override void LayoutSubviews() { + ResolveLayoutChanges(); + base.LayoutSubviews(); if (_blur != null && Superview != null)