View.HorizontalOptions Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the LayoutOptions that define how the element gets laid in a layout cycle. This is a bindable property.
public Xamarin.Forms.LayoutOptions HorizontalOptions { get; set; }
member this.HorizontalOptions : Xamarin.Forms.LayoutOptions with get, set
Property Value
A LayoutOptions which defines how to lay out the element. Default value is Fill unless otherwise documented.
Remarks
Assigning the HorizontalOptions modifies how the element is laid out when there is excess space available along the X axis from the parent layout. Additionally it specifies if the element should consume leftover space in the X axis from the parent layout. If multiple children of a layout are set to expand, the extra space is distributed proportionally.
This example creates four views and adds them to a stack, each laying out in a different manner.
private View CreateButtons ()
{
var button1 = new Button {Text = "LeftAligned", HorizontalOptions=LayoutOptions.Start};
var button2 = new Button {Text = "CenterAligned", HorizontalOptions=LayoutOptions.Center};
var button3 = new Button {Text = "EndAligned", HorizontalOptions=LayoutOptions.End};
var button4 = new Button {Text = "Fill", HorizontalOptions=LayoutOptions.Fill};
StackLayout stack = new StackLayout {
Children = {
button1,
button2,
button3,
button4
}
};
return stack;
}