zperee
zperee

Reputation: 432

Xamarin Forms ActivityIndicator over ListView

My ActivityIndicator is at the bottom of the Page, but it should be in the middle. I tried everything I found in the internet but nothing worked.

Image

<AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

    <StackLayout AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
      <SearchBar Placeholder="Parkhaus suchen" Text="{Binding SearchText}"/>

      <ListView x:Name="HomeListView" ItemsSource="{Binding Parking}" HasUnevenRows="False"  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
        <ListView.ItemTemplate>
          <DataTemplate>
            ...
          </DataTemplate>
        </ListView.ItemTemplate>
        <ListView.Footer/>
      </ListView>
    </StackLayout>

   <StackLayout AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1">
        <ActivityIndicator IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}" VerticalOptions="Center" HorizontalOptions="Center"/>
   </StackLayout>

</AbsoluteLayout>

Upvotes: 1

Views: 2647

Answers (1)

Eugene Pawlik
Eugene Pawlik

Reputation: 1190

Try changing your StackLayout around your ActivityIndicator to use:

AbsoluteLayout.LayoutFlags="PositionProportional"
AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1"

The PositionPropertional flag tells the AbsoluteLayout that the x and y position of the element is based on the size of the absolute layout, taking the size of the element into account. So 0.5 tells it to center the element within the AbsoluteLayout.

The values for the width and height are both set to -1. This is considered a "special value" for width and height meaning "Auto".

Upvotes: 4

Related Questions