maui
maui copied to clipboard
ScrollToAsync Not Working on Andrioid
Description
The Maui ScrollView method scrollView.ScrollToAsync(label, ScrollToPosition.Start, true) works on Windows but fails on Andoid.
I created a very simple demo here: https://github.com/robreno/ScrollToDemo
It is a simple two page app with a ScrollView with a VerticalStackLayout for this main container and then a series of Labels that have x:Name for scrolling to the Label name. When compiled and deployed on Windows the ScrollToAsync works as expected. On Android the app doesn't scroll to the Label name at all.
I have no idea is this a feature or bug ;-) But it seems this is pretty vanilla functionality that Maui framework should handle. Therefore I would call it a bug. But, if I am doing somethign wrong or need to perhaps write custom handlers and call native Android APIs I am willing to do so, but first need to know if this is a bug.
I tried both scrollView.ScrollToAsync(label, ScrollToPosition.Start, true) and scrollView.ScrollToAsync(labelX, labelY, false). Both these work on Windows, neither of them works on Android.
Steps to Reproduce
- Download the demo app, compile and deploy to Windows and then Android.
- GitHub Demo App: https://github.com/robreno/ScrollToDemo
- The code is pretty simple and self contained.
- Watch Video of code: https://youtu.be/Uwy_19Baxes
Link to public reproduction project repository
https://github.com/robreno/ScrollToDemo
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android version 12
Did you find any workaround?
No
Relevant log output
N/A. See demo repo.
Verified this on Visual Studio Enterprise 17.7.0 Preview 2.0. Repro on Android 13.0-API33 with below Project: ScrollToDemo.zip
Android and Windows scroll to different position:
Hmm mine doesnt work on Android or iOS.
Update:
It seems we have to wait for the contents to rendered on the view first before calling ScrollToAsync
Yet another bug that is open for over 8 months. At this rate I will NEVER be able to ship my app into production. This is HELL.
Looks like three's no one actually working on fixing bugs, I think most devs have moved to a different project and the remaining are busy writing blogs or making Youtube videos on how cool MAUI is.
From what I've tried, it works as intended if it's inside the ContentPage's SizeChanged event. I don't think #19515 is related.