Hi. I'm starting with Xamarin and was trying to build my first page. It's a quite simple login page. There are two entries on first two lines. On third line, I want a label on the left and a switch on the right. Finally, the login button at the bottom.
I thought the right way to do this was to first insert a scrollView (for smaller screens). In the scroll view, I then have a StackLayout in vertical mode. Finally, for the switch line, I use a StackLayout in horizontal mode.
So it looks like this
Content = new ScrollView {
VerticalOptions = LayoutOptions.CenterAndExpand,
Content = new StackLayout {
Spacing = 20, Padding = 20,
VerticalOptions = LayoutOptions.CenterAndExpand,
Children = {
userEntry,
pwdEntry,
new StackLayout {
Spacing = 50, Padding = new Thickness(0, 20, 0, 50),
Orientation = StackOrientation.Horizontal,
VerticalOptions = LayoutOptions.CenterAndExpand,
Children = {
new Label {
LineBreakMode = LineBreakMode.WordWrap,
VerticalOptions = LayoutOptions.CenterAndExpand,
Text = "Sample text"
},
loginSwitch
}
},
loginButton
}
}
};
Everything is fine as long as the "Sample text" label is not too long. If I have a text that wraps, the horizontal StackLayout is not expanded properly. It seems the height is updated, because I can see 2 or 3 lines of text if the label is very long. But the height doesn't fit the whole text. Why is the StackLayout not setting its height properly to fit the whole label? The problem does not appear in vertical mode. Is it a known limitation? Should I use another way to render such layout?
Thanks in advance for the help
J.