I have created a new MAUI .NET 8 project and migrated the Xamarin forms project code.
In my project, I used RelativeLayout for UI design on all the pages, now this RelativeLayout is outdated in MAUI.
I used the Compatability namespace to use RelativeLayout in my MAUI project. However, the RelativeLayout is not working properly in MAUI. the position of elements in RelativeLayout working weirdly.
My question is,
RelativeLayout will work properly in MAUI or not?
Do I need to strictly not use RelativeLayout in MAUI? If yes what is the recommended layout in MAUI which similar/alternative to RelativeLayout?
With Grid Layout, we can place an element with an absolute position? like we do in RelativeLayout.
For example, how do I achieve the below RelativeLayout code in Grid Layout,
rtlMain.Children.Add(titleContent, Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.X;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.Y;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.Width;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return (parent.Height > parent.Width ? parent.Height : parent.Width) * .06;
}));
rtlMain.Children.Add(mainContent, Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.X;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return (parent.Height* 0.20);
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.Width;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.Height - (parent.Height * .32);
}));
rtlMain.Children.Add(footerContent, Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.X;
}),Microsoft.Maui.Controls.Compatibility. Constraint.RelativeToParent((parent) =>
{
return parent.Height - (parent.Height > parent.Width ? parent.Height : parent.Width) * 0.08;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return parent.Width;
}), Microsoft.Maui.Controls.Compatibility.Constraint.RelativeToParent((parent) =>
{
return (parent.Height > parent.Width ? parent.Height : parent.Width) * 0.08;
}));