Hello,
This is a known issue in github [Android] ScrollView Orientation=Neither not working #18418.
For this problem, you can use Android's native method to disable or enable scrolling in ScrollView. Please refer to the following steps.
Step 1. Create a touch listener for ScrollView under the Android folder.
internal class MyTouchListener : Java.Lang.Object, IOnTouchListener
{
public AndroidX.Core.Widget.NestedScrollView NestedScroView { get; set; }
public bool ScrollEnabled { get; set; }
public MyTouchListener(bool enabled, NestedScrollView view)
{
NestedScroView = view;
ScrollEnabled = enabled;
}
public bool OnTouch(global::Android.Views.View? v, MotionEvent? e)
{
if (ScrollEnabled==true)
{
return NestedScroView.OnTouchEvent(e);
}
else
{
return true; // If it returns true directly, ScrollView deactivates scrolling behavior.
}
}
}
Step 2. Disable or enable scrolling via the handler settings.
<ScrollView x:Name="scroll">
// disable scrolling
scroll.HandlerChanged += (sender, e) =>
{
#if ANDROID
var s = scroll.Handler.PlatformView as AndroidX.Core.Widget.NestedScrollView;
if (s != null)
{
s.SetOnTouchListener(new MyTouchListener(false,s));
}
#endif
};
// enable scrolling
#if ANDROID
var s = scroll.Handler.PlatformView as AndroidX.Core.Widget.NestedScrollView;
if (s != null)
{
s.SetOnTouchListener(new MyTouchListener(true, s));
}
#endif
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our [documentation][1] to enable e-mail notifications if you want to receive the related email notification for this thread. [1]: https://docs.microsoft.com/en-us/answers/articles/67444/email-notifications.html