如何调整ios的Xamarin表单中的列表视图
问题描述:
我的iOS存在问题。我无法调整它适用于所有的iOS模板,例如:在我的iPhone 7上放置HeightRequest = "855"
,它已经适合正确使用,其他iPhone 5和更小型的我的ListView
。所以我想我的ListView
自动调整到屏幕大小。如何调整ios的Xamarin表单中的列表视图
<ListView x:Name="listView"
CachingStrategy="RecycleElement"
ItemsSource="{Binding FeedItems}"
HasUnevenRows="True"
AbsoluteLayout.LayoutFlags="All"
AbsoluteLayout.LayoutBounds="0,0,1,1" HeightRequest="855">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"/>
<ColumnDefinition Width="5"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<StackLayout HeightRequest = "60" WidthRequest="60">
<Image x:Name="Image" Source="{Binding Image}" Scale="1.0" Aspect="AspectFill" VerticalOptions="FillAndExpand"/>
</StackLayout>
<StackLayout Grid.Column="2" Spacing="4" VerticalOptions="Center">
<Label Text="{Binding Category}" TextColor="White" FontSize="Small" LineBreakMode="NoWrap" BackgroundColor="{Binding Color_category}"/>
<Label Text="{Binding PublishDate}" TextColor="#666666" FontSize="Small" LineBreakMode="NoWrap"/>
<Label Text="{Binding Title}" TextColor="#234084" Font="Bold" FontSize="Small" LineBreakMode="WordWrap"/>
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
答
扩大一点。
HeightRequest
用于想要为元素定义固定大小。 Xamarin将尽最大努力满足这一点。另一方面,当你想要你的尺寸是相对的,你可以使用VerticalOptions
和HorizontalOptions
。这两个属性将采用LayoutOptions结构,其默认值为Fill(不包括展开)。
这个结构有两套物业,那些我称之为 “常规”
中心
开始
末
FLL
而且 “扩展”
CenterAndExpand
StartAndExpand
EndAndExpand
FillAndExpand
您可以阅读莫的那些关于这些here。
这最后一个FillAndExpand
将采取所用方向的所有可用空间。这是你应该在你的ListView
使用,使其那样大屏幕
希望一个本helps.-
不要使用'HeightRequest'对于使用'VerticallOptions =“FillAndExpand”' – apineda