[英]ListView and CollectionView are taking extra space than the required space in Xamarin Forms
[英]Xamarin - CollectionView extra space for first and last item
大家好,
我的問題是我是否能夠在 Xamarin 的 CollectionView 中的第一項上方和最后一項下方添加一些額外的空間。
我有類似圓角卡片的物品,但目前看不清楚,因為第一個物品上方和最后一個物品下方沒有空間。 它們之間的垂直空間可以使用 ItemSpacing 屬性。
我將在此處添加屏幕截圖。 黑線是我需要空間的確切位置。
正如 jason 所說,您可以為 Grid 或 stacklayout 添加 padding 或 Margin,然后在此布局中添加 CollectionView。
<Grid Padding="20">
<CollectionView ItemsSource="{Binding images}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Black" CornerRadius="30">
<StackLayout>
<Image Source="{Binding imagepath}" />
<Label Text="{Binding text}" />
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.