0

When I add 3 ListView-s(cause I have 3 independent groups) in the same ScrollView so that all elements be visible on scrolling the main page, the listview do not resize to show all elements, neither they scroll. My code is:

<ScrollView>
        <StackLayout Spacing="3" Padding="5" 
              Orientation="Vertical" HorizontalOptions="FillAndExpand"
                        VerticalOptions="FillAndExpand">
                        <!-- 
                        Patients en Soins part
                        -->
                        <Label x:Name="listTitle" Text="Patients en Soins"
                            Style="{StaticResource InterSimpleHeaderStyle}" />
                        <ListView x:Name="intervetionsList" Style="{StaticResource ListViewStyle}"
                            IsPullToRefreshEnabled="true" />
                        <!-- 
                        Patients en Coordination part
                        -->
                        <Label x:Name="patientsEnCoordinationTitle" Text="Patients en Coordination"
                            Style="{StaticResource InterSimpleHeaderStyle}" />
                        <ListView x:Name="patientsEnCoordinationList" Style="{StaticResource ListViewStyle}"
                            IsPullToRefreshEnabled="true" HeightRequest="30" />
                        <!-- 
                        Mes archives part
                        -->
                        <Label x:Name="archivesTitle" Text="Mes archives"
                            Style="{StaticResource InterSimpleHeaderStyle}" />
                        <ListView x:Name="archivesList" Style="{StaticResource ListViewStyle}"
                            IsPullToRefreshEnabled="true" HeightRequest="100" />
                    </StackLayout>
</ScrollView>

Can you help me?

idJecan
  • 1
  • 2
  • Don't Do That™: http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android/6211286#6211286 – SushiHangover Mar 24 '17 at 15:34
  • All xamarin.forms guys say that never put a listview inside a scroll view .... – Ahmad ElMadi Mar 24 '17 at 15:37
  • Firstly, it is not a ANDROID question, so @Sushihangover thank you, but the link you send me does not really help me. It's a Xamarin.Forms question. I'am not a fan of this either, but I do not have any other option except this. Xamarin does not offer scrolling in view's that have a content height bigger than the screen, only if you add theme into a scrollView. That's why I need it. I thought of using grouping in a listview, but than I will lost the possibility of refreshing the list independent of the others. – idJecan Mar 27 '17 at 15:19
  • @idJecan It is not an Xamarin.Forms issue, it is an Android issue (and somewhat an iOS issue) in the fact that you (via Forms) are embedding multiple views that require scrolling and that they are auto-sized. You either have to hardcode some heights so the scrollview's parent knows how to set its children's height within that scrollable container or restructure your layout to avoid the issue to start with... – SushiHangover Mar 27 '17 at 15:30
  • @SushiHangover . Thank you for the quick reply. I already compute and set the height of some lists I use in the same way when I have to change the collection. But I do not like it very much. I don't think it should be me to calculate the height a list should take each time I change the collection. I hope I am not wrong. – idJecan Mar 27 '17 at 15:45
  • @idJecan Look at the solutions people have come up with here : https://forums.xamarin.com/discussion/2857/listview-inside-scrollview The short version is you have to calculate the heights somewhere... native renderer or not.... – SushiHangover Mar 27 '17 at 15:56
  • @SushiHangover Thank you :) – idJecan Mar 27 '17 at 15:59

0 Answers0