In my application I need to center an image vertically and horizontally within a ListView
header.
<ListView x:Name="MenuItemsListView"
SeparatorVisibility="None"
HasUnevenRows="true"
ItemsSource="{Binding MenuItems}">
<ListView.Header>
<StackLayout BackgroundColor="Black" HeightRequest="100">
<Image HeightRequest="80" HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand" Source="Assets\logo.png" />
</StackLayout>
</ListView.Header>
</ListView>
I don't understand why the black space under the image is higher than the black space above the image. I tried a Grid
instead of the StackLayout
with row heights 10
, Auto
, 10
with the same result. How can I fix that?