ListView Inside ScrollView Xamarin.Forms WorkAround

This workaround works for Android API 21 and later. For lower API, see this.

Xamarin doesn't recommend using the ListView, WebView, or ScrollView inside a ScrollView.
 

Microsoft Xamarin.Forms Official Documentation says that ScrollViews should not be nested. In addition, ScrollViews should not be nested with other controls that provide scrolling, like ListView and WebView

Some of the Xamarin Experts advise that you shouldn't put a ListView inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all are handled by the parent ScrollView. 
 
Placing ListView inside a ScrollView is not a good idea but still, we are trying to achieve it by writing the Custom Renderer because such features are available in native platforms.
 
Let's prepare the XAML first.
 
MainPage.Xaml 
  1. <ScrollView Padding="20">  
  2.         <StackLayout>  
  3.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  4.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  5.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  6.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  7.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  8.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  9.             <Label Text="Panda Family"></Label>  

  10.             <controls:NestedScroll x:Name="listview"  
  11.                                    MinimumHeightRequest="96"  
  12.                                    Margin="16,0">  
  13.             </controls:NestedScroll>  

  14.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  15.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  16.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  17.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  18.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  19.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  20.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  21.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  22.             <Label Text="Hello!!! Welcome to Smiley Panda"></Label>  
  23.             <Label Text="Hello!!! Smiley Panda Loves you"></Label>  
  24.         </StackLayout>  
  25. </ScrollView>   

Create NestedScroll class 

Now, create a new class for the Custom Renderer in .NET Standard project.
  1. public class NestedScroll : Xamarin.Forms.ListView  
  2.     {  
  3.         public static readonly BindableProperty IsNestedScrollProperty = BindableProperty.Create(  
  4.             propertyName: "IsNestedScroll",  
  5.             returnType: typeof(bool),  
  6.             declaringType: typeof(NestedScroll),  
  7.             defaultValue: false  
  8.             );  
  9.   
  10.         public bool IsNestedScroll  
  11.         {  
  12.             get  
  13.             {  
  14.                 return (bool)GetValue(IsNestedScrollProperty);  
  15.             }  
  16.             set  
  17.             {  
  18.                 SetValue(IsNestedScrollProperty, value);  
  19.             }  
  20.         }  
  21.     }  

Add Namespace in Xaml

Add reference to the XAML for newly created Custom Renderer class.  
  1. xmlns:controls="clr-namespace:NestedScrollTest.CustomRenderer; NestedScrollTest"

Create CustomRenderer for Android 

Now, create another Custom Renderer class for Android in the Android project solution. Override the native view ListViewRenderer of Android and make the NestedScrollingEnabled property true. 
  1. public class NestedScrollDroid: ListViewRenderer  
  2.     {  
  3.         public NestedScrollDroid(Android.Content.Context context) : base(context)  
  4.         {  
  5.   
  6.         }  
  7.         protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)  
  8.         {  
  9.             base.OnElementChanged(e);  
  10.             if(e.NewElement != null)  
  11.             {  
  12.                 var listview = this.Control as Android.Widget.ListView;  
  13.                 listview.NestedScrollingEnabled = true;  
  14.             }  
  15.         }  
  16.     }   
Now, let us add some items in Listview in xaml.cs
  1. public partial class MainPage : ContentPage  
  2.    {  
  3.        public MainPage()  
  4.        {  
  5.            InitializeComponent();  
  6.            listview.ItemsSource = AddPandaFamily();  
  7.        }  
  8.        List<string> pandaFamily = new List<string>();  
  9.        public List<string> AddPandaFamily()  
  10.        {  
  11.            for(int i=0; i<10; i++)  
  12.            {  
  13.                pandaFamily.Add("Smiley Panda");  
  14.                pandaFamily.Add("Red Panda");  
  15.                pandaFamily.Add("Qinling Panda");  
  16.                pandaFamily.Add("Oleosa Panda");  
  17.                pandaFamily.Add("Ailuropoda Panda");  
  18.   
  19.            }  
  20.            return pandaFamily;  
  21.        }  
  22.     }  

Demo

 

 

Source Code