在 RelativeLayout 中,我通过定义高度和 Y 约束得到了最好的结果。
<RelativeLayout>
<StackLayout VerticalOptions="Start" BackgroundColor="Green"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.25}">
<!-- Top Content -->
<Button Text="Top Button" Clicked="Button_OnClicked" />
</StackLayout>
<StackLayout VerticalOptions="Center" BackgroundColor="Aqua"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.30}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.6}">
<!-- Mid Content -->
<Button Text="Mid Button" Clicked="Button_OnClicked" />
</StackLayout>
<StackLayout VerticalOptions="End" BackgroundColor="Yellow"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.90}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.1}">
<!-- Bottom Content -->
<Button Text="Bottom Button" Clicked="Button_OnClicked" />
</StackLayout>
</RelativeLayout>
结果:
