locked
Preventing OverScroll on the ScrollView RRS feed

  • Question

  • User242053 posted

    I can't seem to find a property to handle this, but is it possible to prevent the user from being able to pull a ScrollView down?

    Thursday, July 14, 2016 8:30 PM

All replies

  • User76916 posted

    @JeremyBoyd.5439 - not that I am aware of. If it is an option look to the native controls that Xamarin Forms uses to see if there is an option on there. If so, then you could write a custom renderer for each. However I can't seem to find anything for the Android ScrollView from a quick Google. Its not looking hopeful.

    Monday, July 18, 2016 3:32 AM
  • User383496 posted

    You can write a custom renderer. On android, I use this:

    ```csharp protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (e.NewElement as MyScrollView == null) return;

            OverScrollMode = ((MyScrollView)e.NewElement).IsOverScrollEnabledOnAndroid ?
                Android.Views.OverScrollMode.IfContentScrolls :
                Android.Views.OverScrollMode.Never;
        }
    

    ```

    However, it currently seems to only be working for vertically scrolling scrollViews

    Monday, April 29, 2019 7:07 AM
  • User390843 posted

    @lucidBrot said:

    However, it currently seems to only be working for vertically scrolling scrollViews

    You can also prevent horizontal overscrolling by adding this to the custom renderer on Android: csharp public override void OnViewAdded(View child) { if (child is AHorizontalScrollView hScrollV) hScrollV.OverScrollMode = OverScrollMode.Never; base.OnViewAdded(child); }

    Sunday, January 12, 2020 10:38 PM