Xamarin.Forms: неправильное вычисление высоты списка?

Почему в ярлыках внизу отображается только половина текста?

Это мой xaml. Область просмотра списка - 300, а каждая строка списка - 100 (устанавливается в <On Platform="Android">100</On>).

Каждый ViewCell имеет 4 строки, каждая из которых составляет 25, всего 100 (высота строки списка).

Поэтому я не понимаю, почему отображается только половина текста внизу или почему пространство, занимаемое строками 0 и 1 столбца 2, не является ровно половиной общей высоты.

<Grid RowSpacing="0">
    <Grid.RowDefinitions>
        <RowDefinition Height="100" />
        <RowDefinition Height="300" />
    </Grid.RowDefinitions>
    <StackLayout Grid.Row="0" x:Name="MapGrid">
        <maps:Map WidthRequest="960" HeightRequest="100" 
              x:Name="MyMap" IsShowingUser="true"/>
    </StackLayout>
    <StackLayout Grid.Row="1" x:Name="listSection" HeightRequest="300">
        <ListView x:Name="ListView_Pets">
            <ListView.RowHeight>
                <OnPlatform x:TypeArguments="x:Int32">
                    <On Platform="Android">100</On>
                </OnPlatform>
            </ListView.RowHeight>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="25"></RowDefinition>
                                <RowDefinition Height="25"></RowDefinition>
                                <RowDefinition Height="25"></RowDefinition>
                                <RowDefinition Height="25"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="50*" />
                                <ColumnDefinition Width="25*"/>
                                <ColumnDefinition Width="25*"/>
                            </Grid.ColumnDefinitions>
                            <Label Text="Name" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="Black" Grid.Row="0" Grid.Column="0"/>
                            <Label Text="Address" HorizontalTextAlignment="Center" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" Grid.Row="1" Grid.Column="0"/>
                            <Label Text="Price1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="White" BackgroundColor="#2FA4D9" Grid.Row="0" Grid.Column="2"/>
                            <Label Text="Price2" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="White" BackgroundColor="#2FA4D9" Grid.Row="1" Grid.Column="2"/>
                            <Label Text="Tag1" Grid.Row="0" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Grid.Column="1" FontSize="Micro"/>
                            <Label Text="Tag2" Grid.Row="1" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Grid.Column="1" FontSize="Micro"/>
                            <StackLayout Grid.Row="3" Grid.Column="0">
                                <StackLayout Orientation="Horizontal" >
                                    <Label Text="Text1" FontSize="10" VerticalTextAlignment="Start" TextColor="Black" />
                                    <Label Text="Text2" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" />
                                    <Label Text="Text3" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" />
                                </StackLayout>
                            </StackLayout>
                        </Grid>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackLayout>
</Grid>

Вот скриншот:

введите здесь описание изображения


person fdkgfosfskjdlsjdlkfsf    schedule 27.02.2019    source источник


Ответы (1)


Это связано с тем, что сетка внутри вашей ViewCell имеет значения по умолчанию для RowSpacing и ColumnSpacing. Чтобы изменить это, просто установите <Grid RowSpacing=0 ColumnSpacing=0>

person Armin Rasoulian    schedule 27.02.2019