

Relative constraints are specified by setting the RelativeLayout attached properties to Constraint objects that are returned by the ConstraintExpression markup extension. The following table shows how to specify constraints in XAML and C#:Ībsolute constraints are specified by setting the RelativeLayout attached properties to double values.Ībsolute constraints are specified by the Constraint.Constant method, or by using the Children.Add overload that requires a Func argument.

When constraints aren't specified, a child will be positioned in the upper left corner of the layout. Within a RelativeLayout, the position and size of children are specified as constraints using absolute values or relative values. It will result in the CPU having to perform significantly more work. For more information about attached properties, see Xamarin.Forms Attached Properties.Īvoid using a RelativeLayout whenever possible. These properties are backed by BindableProperty objects, which means that the properties can be targets of data bindings and styled. This property can't be easily consumed from XAML.

YConstraint, of type Constraint, which is an attached property that represents the constraint on the Y position of the child.XConstraint, of type Constraint, which is an attached property that represents the constraint on the X position of the child.

The RelativeLayout class defines the following properties: In addition, unlike some other layout classes, RelativeLayout is able to position children so that overlap. This allows UIs to be created that scale proportionally across device sizes. A RelativeLayout is used to position and size children relative to properties of the layout or sibling elements.
