Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms 如何在xamarin表单的Flex布局中从一开始对齐项目?_Forms_Xamarin_Xamarin.forms - Fatal编程技术网

Forms 如何在xamarin表单的Flex布局中从一开始对齐项目?

Forms 如何在xamarin表单的Flex布局中从一开始对齐项目?,forms,xamarin,xamarin.forms,Forms,Xamarin,Xamarin.forms,我正在使用xamarin forms V3.3.0。我无法从一开始就对齐flex布局最后一行中的项目。我尝试使用这些属性组合,Direction=“Row”Wrap=“Wrap”JustifyContent=“Center”AlignContent=“Start”AlignItems=“Start”。在下面添加了代码和图片 <FlexLayout Direction="Row" Wrap="Wrap" Margin="5" JustifyContent="Center" AlignCo

我正在使用xamarin forms V3.3.0。我无法从一开始就对齐flex布局最后一行中的项目。我尝试使用这些属性组合,Direction=“Row”Wrap=“Wrap”JustifyContent=“Center”AlignContent=“Start”AlignItems=“Start”。在下面添加了代码和图片

<FlexLayout Direction="Row"  Wrap="Wrap" Margin="5" JustifyContent="Center"  AlignContent="Start"  AlignItems="Start">
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>
            <BoxView HeightRequest="100" WidthRequest="100" BackgroundColor="Blue" Margin="5"></BoxView>            
        </FlexLayout>


对于最后一行的这些项目,
JustifyContent=“Center”
显示所有项目都移动到中心

您可以尝试改用
JustifyContent=“Start”


您需要将flexlayout更改为:

<FlexLayout WidthRequest="330" HorizontalOptions="Center"  Wrap="Wrap" Margin="5">


我已经试过了,但我需要在所有设备中保持flex布局的开始和结束的边距相等。在您共享的图像中,右边距大于左边距。然后底部的两个框需要更宽,而FlexLayout不适合您。