【发布时间】:2019-05-18 07:23:12
【问题描述】:
在我的应用程序中,我需要在ListView 标头内将图像垂直和水平居中。
<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>
我不明白为什么图像下方的黑色空间高于图像上方的黑色空间。我尝试了Grid,而不是行高10、Auto、10 的StackLayout,结果相同。我该如何解决?
【问题讨论】:
-
您在
StackLayout上寻找VerticalContentAlignment/HorizontalContentAlignment吗? -
一张截图值一千字……
标签: xaml xamarin.forms xamarin.uwp