我有一个 JSON,其中包含图像缩略图 URL 和一些文本,现在我必须将其呈现为像电话画廊这样的图像画廊。我对网格布局进行了大量研究,但没有找到一种方法来动态创建可以显示图像的固定宽度和高度的网格数量。谁能告诉我设计包含大量图像的画廊类型页面的最佳组件是什么?
最佳答案
您可以使用 this nuget 包并在网格中显示图像。示例代码:
<flv:FlowListView FlowColumnCount="3" SeparatorVisibility="None" HasUnevenRows="false"
FlowItemTappedCommand="{Binding ItemTappedCommand}"
FlowItemsSource="{Binding PhotosList}" >
<flv:FlowListView.FlowColumnTemplate>
<DataTemplate>
<StackLayout>
<Image Source="{Binding Image}" HeightRequest="50" WidthRequest="50"/>
<Label Text="{Binding Name}" TextColor="Black" FontSize="Medium" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" HorizontalOptions="Fill" />
</StackLayout>
</DataTemplate>
</flv:FlowListView.FlowColumnTemplate>
</flv:FlowListView>
其中,PhotosList 将是您的 URL 和文本列表。
关于xaml - 在 xamarin.forms 中设计图片库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29078468/