diff --git a/Xamarin.Forms.Platform.GTK/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.GTK/Renderers/ScrollViewRenderer.cs index 0f7561e2945..4a3659aec07 100644 --- a/Xamarin.Forms.Platform.GTK/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.GTK/Renderers/ScrollViewRenderer.cs @@ -2,7 +2,6 @@ using System; using System.ComponentModel; using Xamarin.Forms.Platform.GTK.Extensions; -using Xamarin.Forms.Platform.GTK.Helpers; namespace Xamarin.Forms.Platform.GTK.Renderers { @@ -10,6 +9,7 @@ public class ScrollViewRenderer : ViewRenderer { private VisualElement _currentView; private Viewport _viewPort; + private Gdk.Rectangle _lastAllocation; protected IScrollViewController Controller { @@ -57,6 +57,40 @@ protected override void OnElementChanged(ElementChangedEventArgs e) } } + protected override void OnSizeAllocated(Gdk.Rectangle allocation) + { + base.OnSizeAllocated(allocation); + + if (IsAnimationRunning(Element)) + { + return; + } + + if (_lastAllocation != allocation) + { + _lastAllocation = allocation; + + Rectangle bounds = Element.Bounds; + Container.MoveTo((int)bounds.X, (int)bounds.Y); + + for (var i = 0; i < ElementController.LogicalChildren.Count; i++) + { + var child = ElementController.LogicalChildren[i] as VisualElement; + + if (child != null) + { + var renderer = Platform.GetRenderer(child); + renderer?.Container.SetSize(child.Bounds.Width, child.Bounds.Height); + + if (!IsAnimationRunning(renderer.Element)) + { + renderer?.Container.MoveTo(child.Bounds.X, child.Bounds.Y); + } + } + } + } + } + protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e);