[英]Adding a boarder to the bottom of a ListView.Header
这是我到目前为止尝试过的:
<ListView RowHeight="50">
<ListView.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="49" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<Label Grid.Row="0" BackgroundColor="#EEEEEE" Text="ABC" />
<BoxView Grid.Row="1" BackgroundColor="#999" HeightRequest="1" />
</Grid>
</ListView.Header>
<ListView.ItemTemplate>
我曾预期会看到顶部区域的颜色为EEE,在其下方的高度为1且颜色为999的线
但是,在EEE颜色和999行之间有一个大约3-4像素高的白色区域。
有谁知道为什么会有这个,以及如何更改它以便999行直接出现在EEE颜色区域的下方?
我认为这是因为网格(6)的默认RowSpacing
值*。 设置<Grid RowSpacing="0">
摆脱它。
尽管如此,如果您的布局与显示的完全一样,我建议您使用StackLayout(带有Spacing="0"
)而不是Grid。 像这样:
<StackLayout Spacing="0">
<Label BackgroundColor="#EEEEEE"
Text="ABC"
HeightRequest="49"/>
<BoxView BackgroundColor="#999"
HeightRequest="1" />
</StackLayout>
结果(首先使用网格,其次使用StackLayout):
在上面的行中使用负边距,因此您的“ ABC”行的底部边距为-6
。
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="49" />
<RowDefinition Height="1" />
</Grid.RowDefinitions>
<Label Grid.Row="0" BackgroundColor="#EEEEEE" Text="ABC" Margin="0,0,0,-6" />
<BoxView Grid.Row="1" BackgroundColor="#999" HeightRequest="1" />
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.