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