Forum Xamarin.Forms

Vertically expand ListView inside an AbsoluteLayout


I have a ListView inside an AbsoluteLayout that doesn't fill the parent vertically, even setting the VerticalOptions to Fill it always leaves some space at the bottom. How can this be achieved?

Best Answer


  • PrabakaranRamasamyPrabakaranRamasamy USMember ✭✭✭

    Have you tried VerticalOptions as FillAndExpand?

  • AlisonFernandesAlisonFernandes USMember ✭✭

    Yes I did!

  • ShannonHaas.5932ShannonHaas.5932 USUniversity ✭✭

    This is how I did it... just one problem, when your list expands further then the screen, the scroll functionality does not behave properly. I am searching for a solution when I came across this post.

     var listView = new ListView
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions = LayoutOptions.Start,
                            ItemsSource = XXX
    AbsoluteLayout.SetLayoutFlags(listView, AbsoluteLayoutFlags.PositionProportional);
                    AbsoluteLayout.SetLayoutBounds(listView, new Rectangle(0f, 0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
  • AlisonFernandesAlisonFernandes USMember ✭✭

    @Shannon_Haas unfortunately that behaviour is not acceptable either. Any news on this? Haven't tested in the newest builds.

  • ShannonHaas.5932ShannonHaas.5932 USUniversity ✭✭

    @AlisonFernandes It seems to be working fine in android. I have not checked it in the latest iOS RC for I am scared to update and break everything. I will back my project up and try it and let you know.

    Just out of curiosity, are you using the listview/absolutelayout in conjunction with an ActivityIndicator that you want to display in the center of the screen. This seems to be a very desired feature among many. It is a rather difficult process for such a common feature.

  • AlisonFernandesAlisonFernandes USMember ✭✭

    @Shannon_Haas yes, plus overlay buttons. AbsoluteLayout enables you to position your visual elements where you want. The only problem I found with it was the fact that I had to dig this up in the forums, the documentation "at the time coding" wasn't that good regarding real use cases.

  • bulubuloabulubuloa USMember ✭✭

    @AlisonFernandes are you found solution to fix this

  • DanielLDanielL PLInsider ✭✭✭✭

    I don't remember if it worked on every platform but you could also wrap ListView inside ContentView. You could try it.

  • AlisonFernandesAlisonFernandes USMember ✭✭

    @DenisRodionov don't know if it actually fixed it but it's a great tip anw, ty!

Sign In or Register to comment.