relative layout (not recommended)

main
syneffort 2 years ago
parent 5123629750
commit c107d6eac5
  1. 4
      XamarinStudy/XamarinStudy/XamarinStudy/App.xaml.cs
  2. 32
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleRelativeLayoutPage.xaml
  3. 20
      XamarinStudy/XamarinStudy/XamarinStudy/Views/SampleRelativeLayoutPage.xaml.cs
  4. 3
      XamarinStudy/XamarinStudy/XamarinStudy/XamarinStudy.csproj

@ -45,7 +45,9 @@ namespace XamarinStudy
//MainPage = new SampleGridLayoutPage();
MainPage = new SampleAbsoluteLayoutPage();
//MainPage = new SampleAbsoluteLayoutPage();
MainPage = new SampleRelativeLayoutPage();
}
protected override void OnStart()

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="XamarinStudy.Views.SampleRelativeLayoutPage">
<ContentPage.Content>
<RelativeLayout>
<!--BoxView Default Size = 40,40-->
<BoxView BackgroundColor="Red"
RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=0}"
RelativeLayout.YConstraint="{ConstraintExpression Type=Constant, Constant=0}"/>
<BoxView BackgroundColor="Green"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Constant=-40}"
RelativeLayout.YConstraint="{ConstraintExpression Type=Constant, Constant=0}"/>
<BoxView BackgroundColor="Blue"
RelativeLayout.XConstraint="{ConstraintExpression Type=Constant, Constant=0}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Constant=-40}"/>
<BoxView BackgroundColor="Yellow"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Constant=-40}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Constant=-40}"/>
<BoxView x:Name="centerBox" Color="Silver"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.33}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.33}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.33}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.33}"/>
<BoxView BackgroundColor="Violet"
RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToView, ElementName=centerBox, Property=Width}"
RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=centerBox, Property=Height}"
RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToView, ElementName=centerBox, Property=Width, Factor=0.33}"
RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToView, ElementName=centerBox, Property=Height, Factor=0.33}"/>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace XamarinStudy.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class SampleRelativeLayoutPage : ContentPage
{
public SampleRelativeLayoutPage()
{
InitializeComponent();
}
}
}

@ -44,6 +44,9 @@
<EmbeddedResource Update="Views\SampleNavigationPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleRelativeLayoutPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Views\SampleStackLayoutPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

Loading…
Cancel
Save