Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Preventing OverScroll on the ScrollView

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?

Tagged:

Answers

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @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.

  • lucidBrotlucidBrot Member ✭✭

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

            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

  • kapselikapseli Member ✭✭

    @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:

    public override void OnViewAdded(View child)
            {
                if (child is AHorizontalScrollView hScrollV) hScrollV.OverScrollMode = OverScrollMode.Never;
                base.OnViewAdded(child);
            }
    
Sign In or Register to comment.