The new ScrollToAsync function seems to work well on iOS and Android until I came across a bug on Android.
When I call ScrollToAsync the animation always jumps back to position 0 in ScrollView, after this it animates to the correct position (somehow the animation starting position always resets to 0)
MyScroll = new ScrollView { Orientation = ScrollOrientation.Horizontal, BackgroundColor = Color.Red };
StackLayout testContent = new StackLayout { Orientation = StackOrientation.Horizontal };
for (int i = 0; i < 30; i++) {
testContent.Children.Add (new Label { Text = "Item" + i, WidthRequest = 100 });
}
MyScroll.Content = testContent;
rl.Children.Add (
MyScroll,
Constraint.Constant(0),
Constraint.Constant(0),
Constraint.RelativeToParent((Parent) => { return Parent.Width; }),
Constraint.Constant(50)
);
And I use the following method to test:
private async void MyTestMethod()
{
await Task.Delay(3000);
await MyScroll.ScrollToAsync (200, 0, true); // Works as expected
await Task.Delay(3000);
await MyScroll.ScrollToAsync (600, 0, true); // Animation jumps back to start of scrollview, and then quickly scrolls to pos 600
await Task.Delay(3000);
await MyScroll.ScrollToAsync (1000, 0, true); // Animation jumps back to start of scrollview, and then quickly scrolls to pos 1000
}
The code above works as expected on iOS and when I implement the scrollview vertically everything works as expected. Bug is only occuring horizontally on Android.