Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Horizontal scrollview within vertical scrollview

$
0
0

I'm currently porting a iOS App to Xamarin.Forms. The app presents a vertical scrollview which contains a list of horizontal scroll views:

 ---------------
|  __    __    _|_    __  
| |A1|  |A2|  |A|3|  |A4| ...
|  --    --    -|-    --  
|---------------|
|  __    __    _|_    __  
| |B1|  |B2|  |B|3|  |B4| ...
|  --    --    -|-    --  
|---------------|
|  __    __    _|_    __  
| |C1|  |C2|  |C|3|  |C4| ...
|  --    --    -|-    --  
|---------------|

The layout is generated with code similar to this:

new ScrollView {
    Orientation = ScrollOrientation.Vertical,
    Content = new StackLayout {
        Orientation = StackOrientation.Vertical,
        Children = {
            new ScrollView {
                Orientation = ScrollOrientation.Horizontal,
                HeightRequest = 150,
                Content = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                        new Label {
                            Text = "A1",
                            WidthRequest = 150,
                            HeightRequest = 150
                        },
                        new Label {
                            Text = "A2",
                            WidthRequest = 150,
                            HeightRequest = 150
                        }....
                    }
                }
            },
            new ScrollView {
                Orientation = ScrollOrientation.Horizontal,
                HeightRequest = 150,
                Content = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                        new Label {
                            Text = "B1",
                            WidthRequest = 150,
                            HeightRequest = 150
                        },
                        new Label {
                            Text = "B2",
                            WidthRequest = 150,
                            HeightRequest = 150
                        },...
                    }
                }
            },
            new ScrollView {
                Orientation = ScrollOrientation.Horizontal,
                HeightRequest = 150,
                Content = new StackLayout {
                    Orientation = StackOrientation.Horizontal,
                    Children = {
                        new Label {
                            Text = "C1",
                            WidthRequest = 150,
                            HeightRequest = 150
                        },
                        new Label {
                            Text = "C2",
                            WidthRequest = 150,
                            HeightRequest = 150
                        },...
                    }
                }
            }
        }
    }
}

On iOS everything works as expected but on Android only the vertical scroll view scrolls. The horizontal scroll view doesn't scroll at all. I know, the documentation for ScrollView says "It is not recommended to nest ScrollView elements, or other elements with scrolling capabilities, like Xamarin.Forms.WebView" but do you see any way to get that working on Android without falling back to native views?


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>