Reputation: 139
I have a stacklayout which has three labels inside it. But when i display it there gap between those labels. I want to avoid the space. Can anybody help me which property will avoid this problem.
Thanks for your help in advance
Upvotes: 4
Views: 5366
Reputation: 4746
Use the Spacing property of the StackLayout to adjust spacing between items.
The following illustrates this:-
StackLayout objStackLayout = new StackLayout()
{
Orientation = StackOrientation.Vertical,
Spacing = 0
};
Label objLabel1 = new Label();
objLabel1.BackgroundColor = Color.Red;
objLabel1.Text = "Red";
objStackLayout.Children.Add(objLabel1);
Label objLabel2 = new Label();
objLabel2.BackgroundColor = Color.Green;
objLabel2.Text = "Green";
objLabel2.Font = Font.OfSize("Arial", 48);
objStackLayout.Children.Add(objLabel2);
Label objLabel3 = new Label();
objLabel3.BackgroundColor = Color.Blue;
objLabel3.Text = "Blue";
objLabel3.Font = Font.OfSize("Arial", 48);
objStackLayout.Children.Add(objLabel3);
Upvotes: 5