Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 54241 on
Developer Community or GitHub if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Created attachment 21030 [details]
Example solution for reproducing the bug
ListView.ScrollTo is broken on Android with animated: false in certain use cases. I'm not sure exactly what causes it, but it seems to happen if ListView.ScrollTo is called very soon after the view is instantiated, e.g. before its the view's constructor completes.
The call will appear to have no effect with animated: false. (bad)
The call will scroll the list correctly if ListView.ScrollTo is called with animated: true. (good)
This only affects Android.
Tested on Xamarin.Forms 184.108.40.206 and 220.127.116.11
Also see https://forums.xamarin.com/discussion/comment/262351#Comment_262351.
Run the sample solution. You will need to swap between commenting out lines 23 and 24 of MainPage.xaml.cs to test each case.
## Expected behavior
The list scrolls the list item "30" into view when the page loads.
## Actual behavior
Android, animated: false - The list does not scroll at all. (bad)
Android, animated: true - The list scrolls list item "30" into view when the page loads. (good)
iOS, animated: false - The list scrolls list item "30" into view when the page loads. (good)
iOS, animated: true - The list scrolls list item "30" into view when the page loads. (good)
The documentation at https://developer.xamarin.com/api/member/Xamarin.Forms.ListView.ScrollTo/p/System.Object/Xamarin.Forms.ScrollToPosition/System.Boolean/ should specify what will happen when calls are made to ScrollTo before the ListView is rendered.
I am assuming it has not been rendered before the ScrollTo call in the example, but I am not 100% sure.
The source code of Xamarin.Forms.Platform.Android.ListViewRenderer includes a field "_pendingScrollTo". At a glance, it seems the ScrollTo request should be stored until the ListView is rendered, at which point the scroll should happen.
Hi Chase, thank you for filing this report! Let me run the attached project to see if I can confirm this issue and I will update the report with my results.
I was able to reproduce this issue so I will confirm the report.
However, I was only able to reproduce this on an Android 5.0 (API 21). The ListView scrolled as expected when I ran the project on an Android 4.2, 4.4 and 6.0 emulator, and 6.0 device. Are you testing with Android 5.0, or are you seeing this issue on other versions?
I also tested calling ScrollTo() inside OnAppearing() instead, but the issue still occurred unless I added a small (500ms) delay. So this could be used as another workaround if you do not want to enable the animation.
### Version Tests
Jimmy: I used an emulator. Intel Atom x86, Android 6.0 API level 23.