Je suis très nouveau sur Xamarin.Forms pour créer une application universelle. En fait, je dois migrer une grande application native vers la technologie Xamarin.Forms.Xamarin.Forms Universal App 2 Colonne Mise en page indépendante de la taille de l'appareil
Je dois créer une disposition à deux colonnes (par exemple la page d'enregistrement) qui est indépendante de la taille du périphérique. J'essaye de réaliser la même chose en utilisant RelativeLayout. Code pour le même est ci-dessous:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage BackgroundColor="Yellow" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="LearningXamarin.Views.TestPage">
<ContentPage.Content>
<RelativeLayout>
<StackLayout x:Name="mainLayout" BackgroundColor="Maroon" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=0}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=0}">
<RelativeLayout>
<BoxView x:Name="firstView" BackgroundColor="Yellow" HeightRequest="30"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=X, Factor=0, Constant=5}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Y, Factor=0, Constant=20}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.48, Constant=0}"
/>
<BoxView BackgroundColor="Green" HeightRequest="30"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=firstView, Property=Width, Factor=1, Constant=10}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=firstView, Property=Y, Factor=1, Constant=0}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=firstView, Property=Width, Factor=1, Constant=0}"
/>
</RelativeLayout>
</StackLayout>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>
S'il vous plaît Suggest est-ce la bonne façon de réaliser la mise en page à deux colonnes ou est-il une autre façon correcte.
Je vais essayer une grille avec deux colonnes au lieu – Jason