Bug 28570 - ScrollView.ScrollToAsync(); does not respect new content size when content is added
Summary: ScrollView.ScrollToAsync(); does not respect new content size when content is...
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.4.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-03-31 00:06 UTC by Cody Beyer (MSFT)
Modified: 2016-03-16 01:48 UTC (History)
7 users (show)

Tags: android functional scrollview ac
Is this bug a regression?: ---
Last known good build:


Attachments
first click does not scroll (but should). second click scrolls (744.04 KB, application/x-zip-compressed)
2015-05-27 18:13 UTC, philip
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Cody Beyer (MSFT) 2015-03-31 00:06:06 UTC
### Description

The following sample app uses a scrollview, and has a button which makes the content size bigger. Once you make the size bigger, you are no longer able to scroll to the end of the content

### Test Case

https://www.dropbox.com/s/4mxe0u9boushyce/FormsGallery.zip?dl=0

### Steps to Reproduce

1. Open linked test case
2. Deploy to Android simulator
3. Click Scroll
4. Manually scroll back to the top
5. Click Embiggen
6. Click Scroll again

### Expected Results

The view should scroll to the end both times

### Actual Results

The view scrolls to the end at step 3, but at step 6 scrolls again to the end of the smaller text

### Version

=== Xamarin Studio ===

Version 5.9 (build 355)
Installation UUID: 48d20a9d-ef72-44de-8690-d8fa00873cc7
Runtime:
	Mono 3.12.1 ((detached/b63df7d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010002

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.1.9 (Business Edition)
Hash: 7e1f69e
Branch: 
Build date: 2015-03-12 15:35:49-0400

=== Xamarin.Android ===

Version: 4.20.1.0 (Business Edition)
Android SDK: /Users/codybeyer/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.2   (API level 17)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 1.12.0.14 (Business Edition)

=== Build Information ===

Release ID: 509000355
Git revision: 687867254ec3248519ca337fc1c441e7ca9a30db
Build date: 2015-03-30 11:51:21-04
Xamarin addins: cfbd7db36ab63658f7ac03cde8c2ff467f08c278

=== Operating System ===

Mac OS X 10.10.2
Darwin Codys-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0
    Thu Feb 26 19:26:47 PST 2015
    root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Comment 1 Abhishek 2015-03-31 07:16:23 UTC
I have tried this issue and able to reproduce the reported behavior at my end.

Steps to Reproduce:
1. Download the test sample from the above given link.
2. Run the application on the device/Emulator.
3. Click on "ScrollView" Button .
4. Then Click on "Scroll" button it will scroll down to the end.
5. Click on "Embiggen" Button it will increase the font size.
6. Again click on "Scroll" button it will scroll down at the middle.

Screencast: http://www.screencast.com/t/NINBqW8Wy
Application Output:https://gist.github.com/Abhishekk360/332f1b0d1d58e0ea3921
Android Device Log:https://gist.github.com/Abhishekk360/641a472e13666adec096
IDE log:https://gist.github.com/Abhishekk360/e2b7bd6d215f08ddff1d

Environment Info:

Xamarin.Forms: 1.4.1.6349
=== Xamarin Studio ===

Version 5.8.2 (build 7)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
Runtime:
	Mono 3.12.1 ((detached/0849ec7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010003

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.2.4 (Business Edition)
Hash: 981acb3
Branch: 
Build date: 2015-03-25 14:21:05-0400

=== Xamarin.Android ===

Version: 4.20.1.0 (Business Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.Mac ===

Version: 2.0.0.175 (Business Edition)

=== Build Information ===

Release ID: 508020007
Git revision: 067ed06873402cf780f8a0899bb332c2a1c0af22
Build date: 2015-03-27 14:17:13-04
Xamarin addins: 02510c4990dee3475c282b3182d588975a63ff07

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 2 philip 2015-03-31 15:18:08 UTC
The following sequence also has the same problem:

changeScrollviewContentSize();
scrollView.ForceLayout();
await scrollView.ScrollToAsync(...);

This can be made to work with the following kludge (adding Delay):

changeScrollviewContentSize();
scrollView.ForceLayout();
await Task.Delay(10);
await scrollView.ScrollToAsync(...);
Comment 3 philip 2015-05-06 17:19:29 UTC
Any updates on fixing this issue?
Comment 4 Chris King 2015-05-27 17:09:03 UTC
We'd be happy to help you resolve this issue. Please help us by attaching a reduced reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue. If you'd do this for us we would very much appreciate it. The dropbox link is missing. Are you able to attach the solution file and code directly to the bug?

Warm regards,
Xamarin Forms Team
Comment 5 philip 2015-05-27 17:45:13 UTC
Hi Chris.

I will create a sample and post today or tomorrow...

Cheers
Comment 6 philip 2015-05-27 18:13:11 UTC
Created attachment 11362 [details]
first click does not scroll (but should). second click scrolls

The screen shots in the Screenshots folder show the app before click, after first click, and after second click.

The screen shot after first click should be the same as after second click, but the scrollview does not scroll correctly the first time.
Comment 7 Cody Beyer (MSFT) 2015-06-18 18:35:24 UTC
Confirmed using newly provided sample
Comment 8 philip 2015-07-18 16:30:45 UTC
Any ETA for a fix?
Comment 9 Jason Smith [MSFT] 2015-07-22 18:11:20 UTC
Found the issue.

Test case is wrong however. The button click event should look like this: 

> makeBig.Clicked += (object sender, EventArgs e) => {
> 				Lab1.FontSize = Device.GetNamedSize (NamedSize.Large, typeof (Label));
> 				scrollView.ScrollToAsync (0, Lab1.Bounds.Bottom, false);
> 			};

Notice that I am scrolling to the bottom of the label, not the bottom of the ScrollView. scrollView.Height corresponds to the exterior height of the scrollview, not the interior size.
Comment 10 Jason Smith [MSFT] 2015-07-22 18:12:05 UTC
I meant to amend there is still an issue with the layout delay caused by android. When the branch is merged this bug will get marked resolved fixed with a version.
Comment 11 philip 2015-07-22 21:08:58 UTC
Glad you found it.  I will test again in my app when the fix is published.
Comment 12 philip 2015-09-16 15:12:47 UTC
You guys should update your bugs when they are fixed :)  This now works for Android!
Comment 13 Samantha Houts [MSFT] 2016-03-16 01:48:57 UTC
Thank you for taking the time to submit this report. After reviewing the description of this bug, we no longer believe it affects the current version of Xamarin.Forms. If you are still experiencing the issue after updating your packages, please reopen this report with an attached reproduction.
 
For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d

Warm regards,
Xamarin Forms Team