dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

[Android] ScrollView Orientation=Neither not working #18418

Open riccardominato opened 1 year ago

riccardominato commented 1 year ago

Description

Setting ScrollView Orientation option to Neither seems not to have effect on Android.

Steps to Reproduce

  1. Set this as the content of a ContentPage
<ScrollView
    Orientation="Neither">
    <ContentView
        HeightRequest="2000">
        <Label
            Text="Hello world!"
            VerticalTextAlignment="End" />
    </ContentView>
</ScrollView>

Expected result: I shouldn't be able to scroll and see the Hello World label. Actual result: I can scroll until I see the Hello World label.

Link to public reproduction project repository

https://github.com/Riccardo11/MauiIssues/tree/main/ScrollViewOrientationNeither

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13. Didn't test other Android versions.

Did you find any workaround?

Setting IsEnabled attribute to false could be a workaround for someone to do something similar to the expected behavior. Unfortunately, that's not my case.

<ScrollView IsEnabled="False">

Relevant log output

No response

drasticactions commented 1 year ago

This is not Android-specific. The same thing seems to occur on Windows with that code block if you use "Neither" or "Horizontal"

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.8.0 Preview 5.0(8.0.0-rc.2.9373). Repro on Windows 11 with below Project: ScrollViewOrientationNeither.zip

roubachof commented 9 months ago

temporary workaround for this: https://www.sharpnado.com/net-maui-disable-scrolling-on-android/

Jeanjean commented 1 week ago

Yes, sharpnado's workaround mentioned above worked for me, except that I have modified it to map the IScrollView.Orientation property instead of the IScrollView.IsEnabled property. In MauiScrollViewEnable instead of UpdateIsEnabled(bool isEnabled) I now have:

    public void UpdateOrientation(ScrollOrientation orientation)
    {
        _disableScrolling = orientation == ScrollOrientation.Neither;
    }

The reason for this is that setting IsEnabled of my scroll view to false was also affecting the child elements in my scroll view which I didn't want.

nathenxbrewer commented 1 week ago

temporary workaround for this: https://www.sharpnado.com/net-maui-disable-scrolling-on-android/

System.InvalidCastException: Specified cast is not valid. at ScrollViewEnableHandler.<>c.<.ctor>b__0_0(IScrollViewHandler handler, IScrollView view) in

Not sure why, but when I try Sharpnado's workaround, my app crashes when entering the page with the ScrollView