I have a signup page with a few labels and entries, it works fine in portrait, but when in landscape, especially in the UWP, the entries takes the width of the whole screen.
Is there a way to set the layout/view not to exceed a certain width?
AbsoluteLayout. Use the AbsoluteLayout when you need precise control over the x and y positions, and the width and height of the child elements. It has its place in the layout world. In most situations, it's better to use one of the other layouts; they make for a more responsive design.
The Xamarin. Forms FlexLayout is new in Xamarin. Forms version 3.0. It is based on the CSS Flexible Box Layout Module, commonly known as flex layout or flex-box, so called because it includes many flexible options to arrange children within the layout.
Grid. A Grid is used for displaying elements in rows and columns, which can have proportional or absolute sizes.
I figured it out, the `WidthRequest" will try to get the requested width, if not it will take the width available by the parent item. So basically, we do not need a maximum width property.
You can use WidthRequest and HeightRequest or LayoutOptions(HorizontalOptions and VerticalOptions) for better positioning of views inside Layout
You can use the SizeChanged event of the Page to customize the layout when switching to/from portrait/landscape mode :
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent ();
SizeChanged += OnSizeChanged;
}
void OnSizeChanged (object sender, EventArgs e)
{
// Customize your layout here (i.e. using HeightRequest/WidthRequest)...
}
}
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With