Xamarin表单上的FlexLayout,不是填充项行为?

时间:2018-10-15 05:42:27

标签: ios user-interface xamarin.forms

我用Flexlayout创建了一个简单的页面。如预期的那样,如果每行中有空项目,则项目在每行中均匀分布,但在第二行中不相等。 如您在这张图片上看到的:

FlexLayout uneven item number issue

这是我使用的代码:

 <Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="0.1*"/>
        <RowDefinition Height="0.8*"/>
        <RowDefinition Height="0.1*"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <StackLayout Grid.Row="0">
        <Label Text="Header Stacklayout Label" HorizontalOptions="Center"/>
    </StackLayout>
    <ScrollView  Grid.Row="1" HorizontalOptions="Start" VerticalOptions="Start">
        <FlexLayout Direction="Row" AlignItems="Start" JustifyContent="SpaceEvenly" Wrap="Wrap" >
            <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/>
            <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/>
            <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/>
            <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/>
            <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/>

        </FlexLayout>
    </ScrollView>
    <StackLayout Grid.Row="2">
        <Label Text="Footer Stacklayout Label" HorizontalOptions="Center"/>
    </StackLayout>
</Grid>

我期望期望项目在所有行之间均匀分布,但也要平均分布。最后2个项目应在左侧对齐,并且项目的最后一个空白。我相信这是在Bootstrap和类似系统中实现的方式。

1 个答案:

答案 0 :(得分:1)

如果要获得如下屏幕截图所示的视图 enter image description here

只需将$path = getcwd(); $new = str_replace(array("C:", "\"), ("","/") $path); echo $new; 的值设置为JustifyContent

Start

有关<FlexLayout Direction="Row" AlignItems="Start" JustifyContent="Start" Wrap="Wrap" > <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/> <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/> <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/> <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/> <Label Text="FlexLayout" FontSize="Large" WidthRequest="120" HeightRequest="50" HorizontalTextAlignment="Center" BackgroundColor="Silver"/> </FlexLayout> 的更多信息,您可以访问here