Heyo,
所以在Xamarin我有一个< Grid>使用< Image>并在其中包含一对< Label>,所有这些都包含在< ViewCell>内.这在Xamarin.Android中看起来完全没问题,但是在Xamarin.iOS中,图像与标签重叠.我不确定它的区别是什么 – 为什么它在Xamarin.Android中看起来不错但在iOS中它的全部都不稳定?
下面是我的XAML和几个模型来展示我的意思.
<ListView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <Grid> <Grid.ColumnDefinitions> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Image Grid.Column="0" Grid.Row="0" Aspect="AspectFill" Source="{Binding ImageOverlayEN}" /> <Label Grid.Column="0" Grid.Row="1" VerticalTextAlignment="Start" LineBreakMode="WordWrap" Text="{Binding DynamicOfferText}" FontSize="18"> <Label.FontFamily> <OnPlatform x:TypeArguments="x:String"> <OnPlatform.iOS>RobotoCondensed-Regular</OnPlatform.iOS> <OnPlatform.Android>RobotoCondensed-Regular.ttf#RobotoCondensed-Regular</OnPlatform.Android> <OnPlatform.WinPhone>RobotoCondensed-Regular.ttf#RobotoCondensed</OnPlatform.WinPhone> </OnPlatform> </Label.FontFamily> </Label> <Label Grid.Column="0" Grid.Row="2" VerticalTextAlignment="Start" LineBreakMode="WordWrap" Text="{Binding DynamicOfferDetail}" FontSize="16"> <Label.FontFamily> <OnPlatform x:TypeArguments="x:String"> <OnPlatform.iOS>RobotoCondensed-Regular</OnPlatform.iOS> <OnPlatform.Android>RobotoCondensed-Regular.ttf#RobotoCondensed-Regular</OnPlatform.Android> <OnPlatform.WinPhone>RobotoCondensed-Regular.ttf#RobotoCondensed</OnPlatform.WinPhone> </OnPlatform> </Label.FontFamily> </Label> </Grid> </ViewCell.View> </ViewCell> </DataTemplate> </ListView.ItemTemplate>
我尝试设置HeightRequest,但似乎没有什么区别:
#if __IOS__ if (viewmodel.Items.Count > 0) { MyListView.HeightRequest = 300 * viewmodel.Items.Count; } #endif
以下是正在发生的事情的直观表示: