diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue15066.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue15066.cs new file mode 100644 index 00000000000..11efafb20f9 --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue15066.cs @@ -0,0 +1,42 @@ +using Xamarin.Forms.CustomAttributes; + +namespace Xamarin.Forms.Controls.Issues +{ + [Issue(IssueTracker.Github, 15066, "StackLayout's layout inside ScrollView is not updated properly when adding children", + PlatformAffected.Android)] + public class Issue15066 : TestContentPage + { + protected override void Init() + { + var instructions = new Label + { + BackgroundColor = Color.AntiqueWhite, + Padding = 3, + Text = "Tap the 'Add' button until the added items are past the bottom of the screen." + + " Then scroll down - if there is any blue visible at the bottom, this test has failed." + }; + + var scrollView = new ScrollView() { BackgroundColor = Color.DarkBlue }; + + var layout = new StackLayout() { BackgroundColor = Color.DarkGreen }; + + var button = new Button() { Text = "Add" }; + + button.Clicked += (sender, args) => { + layout.Children.Add(new StackLayout() { BackgroundColor = Color.Gray, HeightRequest = 40.0 }); + }; + + layout.Children.Add(instructions); + layout.Children.Add(button); + + for (int n = 0; n < 8; n++) + { + layout.Children.Add(new StackLayout() { BackgroundColor = Color.Gray, HeightRequest = 40.0 }); + } + + scrollView.Content = layout; + + Content = scrollView; + } + } +} diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index ff485b8a1ab..9ab750319c5 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -53,6 +53,7 @@ Issue14801.xaml + Issue8804.xaml diff --git a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs index 91677a32a5b..e2de3548f48 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ScrollViewRenderer.cs @@ -287,6 +287,16 @@ protected override void OnLayout(bool changed, int left, int top, int right, int _checkedForRtlScroll = true; } + protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) + { + if (Element is Layout layout) + { + layout.ResolveLayoutChanges(); + } + + base.OnMeasure(widthMeasureSpec, heightMeasureSpec); + } + protected override void OnScrollChanged(int l, int t, int oldl, int oldt) { _checkedForRtlScroll = true;