Боюсь, вы должны сделать это в коде, и вот пример, который я попытался:
public MainPage()
{
InitializeComponent();
RelativeLayout layout = new RelativeLayout();
BoxView redBox = new BoxView() {BackgroundColor = Color.Red };
BoxView blueBox = new BoxView() { BackgroundColor = Color.Blue };
layout.Children.Add(redBox, Constraint.RelativeToParent((parent) => {
return parent.X;
}), Constraint.RelativeToParent((parent) => {
return parent.Y * .15;
}), Constraint.RelativeToParent((parent) => {
return parent.Width;
}), Constraint.RelativeToParent((parent) => {
return parent.Height * .8;
}));
layout.Children.Add(blueBox, Constraint.RelativeToView(redBox, (Parent, sibling) => {
return sibling.X + 20;
}), Constraint.RelativeToView(redBox, (parent, sibling) => {
return sibling.Y + redBox.Height;
}), Constraint.RelativeToParent((parent) => {
return parent.Width * .5;
}), Constraint.RelativeToParent((parent) => {
return parent.Height * .5;
}));
Content = layout;
}
Или определить элементы управления в xaml и изменить YConstraint
в коде:
RelativeLayout.SetYConstraint(blueBox, Constraint.RelativeToView(redBox, (parent, sibling) =>
{
return sibling.Y + sibling.Height;
}));
В xaml:
<RelativeLayout>
<BoxView Color="Red" x:Name="redBox"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,
Property=Height,Factor=.15,Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Width,Factor=1,Constant=0}"
RelativeLayout.HeightConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Height,Factor=.4,Constant=0}" />
<BoxView Color="Blue" x:Name="blueBox"
RelativeLayout.YConstraint="{ ConstraintExpression Type=RelativeToView,ElementName=redBox,Property=Y,Factor= 1, Constant= 0}"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView,
ElementName=redBox,Property=X,Factor=1,Constant=20}"
RelativeLayout.WidthConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Width,Factor=.5,Constant=0}"
RelativeLayout.HeightConstraint="{ConstraintExpression
Type=RelativeToParent,Property=Height,Factor=.5,Constant=0}" />
</RelativeLayout>
Кстати, вы можете легко достичь этого макета, используя Grid (с одним столбцом) или Vertical StackLayout.