7
votes

In my Xamarin forms application, there are multiple ListView controls inside a ScrollView. But in android the scrolling is not working for ListView. Is there any alternative solution?

5
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. forums.xamarin.com/discussion/2857/listview-inside-scrollviewAkash Amin

5 Answers

9
votes

You SHOULD NOT include ListViews into ScrollView as it system will confuse scrolling behavior of those two. You need to redesign your page with this in mind.

Example: 1) Use ListViews inside StackLayout 2) Use TableViews inside ScrollView

8
votes

You can simply do with set 'NestedScrollingEnabled' property true for native side. For xamarin forms you can create a custom renderer and set 'NestedScrollingEnabled' property true

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.ListView> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null)
        {
            var listView = this.Control as Android.Widget.ListView;
            listView.NestedScrollingEnabled = true;               
        }            
    }
3
votes

ListView implements its own scrolling that might conflict with the ScrollView.

If you need to be able to scroll both lists in the same ScrollView you could for example create custom views (instead of using cells), placing them in a StackLayout inside a ScrollView

More about ListView performance, they even explain why you shouldn't place a ListView inside a ScrollView

0
votes

Have you looked into using one listview with groups instead of multiple listviews?

0
votes

I use any row of grid it will fix to that height & listview will not scroll