Bug 52071 - Xamarin Forms ScrollView api ignores horizontal dimension on Android
Summary: Xamarin Forms ScrollView api ignores horizontal dimension on Android
Status: CONFIRMED
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.3
Hardware: PC Windows
: Normal major
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-01-31 15:44 UTC by Lars Hammer
Modified: 2017-06-06 13:44 UTC (History)
3 users (show)

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


Attachments
Reproduction project (330.97 KB, application/x-zip-compressed)
2017-03-24 22:51 UTC, Paul DiPietro [MSFT]
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 for Bug 52071 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 original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Lars Hammer 2017-01-31 15:44:04 UTC
With a fresh Cross Platform solution using PCL in Visual Studio, please paste in this App.cs and observe that while UWP works fine there are two issues on Android (I have tried the 5" and 7" KitKat simulators):
1) The ScrollX and ScrollY properties on ScrollView are never both different from zero (even with content scrolled in both directions)
2) The x parameter of ScrollView.ScrollToAsync is completely ignored

These issues seem related to this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=42883 and before creating github and bugzilla accounts, I also reported this issue here: https://developercommunity.visualstudio.com/content/problem/15856/xamarin-forms-scrollview-api-ignores-horizontal-di.html 

I am using VS 2017 Community RC, 15.0.16020.0 with the Xamarin.Forms nuget package 2.3.3.180

---- code for App.cs: ----
using Xamarin.Forms;
namespace Scroll101 {
    public class App : Application {
        public App() {
            Button b1, b2, b3, b4;
            Label bug;
            ScrollView scroll;
            var content = new ContentPage {
                Title = "Scrolling 101",
                Content = new StackLayout {
                    Children = {
                        new StackLayout { Orientation = StackOrientation.Horizontal, Children = {
                            (b1 = new Button { Text = "0; 0" }),
                            (b2 = new Button { Text = "101; 0"}),
                            (b3 = new Button { Text = "0; 101"}),
                            (b4 = new Button { Text = "101; 101"}) } },
                        (scroll = new ScrollView { Orientation = ScrollOrientation.Both,
                            Content = bug = new Label() }) } } };
            b1.Clicked += (s, e) => scroll.ScrollToAsync(0, 0, true);
            b2.Clicked += (s, e) => scroll.ScrollToAsync(101, 0, true);
            b3.Clicked += (s, e) => scroll.ScrollToAsync(0, 101, true);
            b4.Clicked += (s, e) => scroll.ScrollToAsync(101, 101, true);
            scroll.Scrolled += (s, e) => content.Title = $"{scroll.ScrollX}; {scroll.ScrollY}";
            bug.Text =
                "Please try the buttons and also simply drag this content both horizontically and vertically " +
                "while observing the values in the page title.\r\n " +
                "On Android (at least on the VS 7\" KitKat emulator) there are two issues:\r\n" +
                " 1) The ScrollX and ScrollY are never both non-zero, even when the content is scrolled in both directions.\r\n" +
                " 2) The x parameter of ScrollToAsync seems to be ignored\r\n" +
                "On UWP this works as expected\r\n";
            for (int i = 0; i < 7; i++)
                bug.Text += bug.Text;
            MainPage = new NavigationPage(content);
        }
        protected override void OnStart() { }
        protected override void OnSleep() { }
        protected override void OnResume() { }
    }
}
Comment 1 Lars Hammer 2017-01-31 19:21:36 UTC
This simpler repro indicates that the problem lies with the ScrollView itself - not with it being hosted in a StackLayout as in the first code. Hope it's useful :-)

using Xamarin.Forms;
namespace Scroll101 {
    public class App : Application {
        public App() {
            Label bug;
            ScrollView scroll;
            var content = new ContentPage {
                Title = "Scrolling 101",
                Content = scroll = new ScrollView { Orientation = ScrollOrientation.Both, Content = bug = new Label() }
                };
            scroll.Scrolled += (s, e) => content.Title = $"{scroll.ScrollX}; {scroll.ScrollY}";
            bug.Text =
                "Please try to simply drag this content both horizontically and vertically " +
                "while observing the values in the page title.\r\n " +
                "On Android (at least on the VS 7\" KitKat emulator) the ScrollX and ScrollY are never both non-zero, " +
                "even when the content is scrolled in both directions.\r\n" +
                "On UWP this works as expected\r\n";
            for (int i = 0; i < 7; i++)
                bug.Text += bug.Text;
            MainPage = new NavigationPage(content);
        }
        protected override void OnStart() { }
        protected override void OnSleep() { }
        protected override void OnResume() { }
    }
}
Comment 2 Lars Hammer 2017-02-03 23:37:59 UTC
FWIW, this bug still repros on Xamarin Forms v2.3.4.192-pre2 - tested using the Visual Studio Emulator for Android with a Marshmallow profile.
Comment 3 Paul DiPietro [MSFT] 2017-03-24 22:51:14 UTC
Attaching a reproduction project.
Comment 4 Paul DiPietro [MSFT] 2017-03-24 22:51:30 UTC
Created attachment 20838 [details]
Reproduction project