<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="XamlSamples.RelativeLayoutPage"
             Title="RelativeLayout Page">

  <RelativeLayout>

    <!-- Upper left -->
    <BoxView Color="Red"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=Constant, 
                                        Constant=0}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=Constant, 
                                        Constant=0}" />
    <!-- Upper right -->    
    <BoxView Color="Green"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=RelativeToParent, 
                                        Property=Width,
                                        Factor=1,
                                        Constant=-40}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=Constant, 
                                        Constant=0}" />
    <!-- Lower left -->
    <BoxView Color="Blue"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=Constant, 
                                        Constant=0}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=RelativeToParent, 
                                        Property=Height,
                                        Factor=1,
                                        Constant=-40}" />
    <!-- Lower right -->
    <BoxView Color="Yellow"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=RelativeToParent, 
                                        Property=Width,
                                        Factor=1,
                                        Constant=-40}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=RelativeToParent, 
                                        Property=Height,
                                        Factor=1,
                                        Constant=-40}" />
    
    <!-- Centered and 1/3 width and height of parent -->
    <BoxView
             Color="Red"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=RelativeToParent,
                                        Property=Width,
                                        Factor=0.33}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=RelativeToParent,
                                        Property=Height,
                                        Factor=0.33}" 
             RelativeLayout.WidthConstraint=
                 "{ConstraintExpression Type=RelativeToParent,
                                        Property=Width,
                                        Factor=0.33}"
             RelativeLayout.HeightConstraint=
                 "{ConstraintExpression Type=RelativeToParent,
                                        Property=Height,
                                        Factor=0.33}"  />
    
    <!-- 1/3 width and height of previous -->
    <BoxView Color="Blue"
             RelativeLayout.XConstraint=
                 "{ConstraintExpression Type=RelativeToView,
                                        ElementName=oneThird,
                                        Property=X}"
             RelativeLayout.YConstraint=
                 "{ConstraintExpression Type=RelativeToView,
                                        ElementName=oneThird,
                                        Property=Y}"
             RelativeLayout.WidthConstraint=
                 "{ConstraintExpression Type=RelativeToView,
                                        ElementName=oneThird,
                                        Property=Width,
                                        Factor=0.33}"
             RelativeLayout.HeightConstraint=
                 "{ConstraintExpression Type=RelativeToView,
                                        ElementName=oneThird,
                                        Property=Height,
                                        Factor=0.33}"  />
  </RelativeLayout>
</ContentPage>