简体   繁体   中英

Xamarin forms ListView inside ScrollView issue

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?

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

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;               
        }            
    }

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

您是否考虑过使用一个列表视图而不是多个列表视图?

我使用它将固定到该高度的任何一行网格而listview将不会滚动

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM