Skip to content

Instantly share code, notes, and snippets.

@amay077
Created March 17, 2017 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amay077/5ae0255b3e16f4467a90e94c7ec14208 to your computer and use it in GitHub Desktop.
Save amay077/5ae0255b3e16f4467a90e94c7ec14208 to your computer and use it in GitHub Desktop.
Xamarin.Forms で上下等間隔2分割のレイアウトを行うサンプル
<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:SepTest" x:Class="LayoutTest.LayoutTestPage">
<ContentPage.Content>
<!--Grid を使う方法-->
<!--
<Grid HorizontalOptions="Fill" VerticalOptions="Fill">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<BoxView Grid.Row="0" BackgroundColor="Aqua" />
<BoxView Grid.Row="1" BackgroundColor="Lime" />
</Grid>
-->
<!--StackLayout を使う方法-->
<!--
<StackLayout VerticalOptions="Fill" HorizontalOptions="Fill">
<BoxView BackgroundColor="Aqua" VerticalOptions="FillAndExpand" />
<BoxView BackgroundColor="Lime" VerticalOptions="FillAndExpand" />
</StackLayout>
-->
<!--RelativeLayout を使う方法-->
<RelativeLayout VerticalOptions="Fill" HorizontalOptions="Fill">
<BoxView BackgroundColor="Aqua"
RelativeLayout.WidthConstraint
= "{ConstraintExpression Type=RelativeToParent,Property=Width, Factor=1.0}"
RelativeLayout.HeightConstraint
= "{ConstraintExpression Type=RelativeToParent,Property=Height, Factor=0.5}"
/>
<BoxView BackgroundColor="Lime"
RelativeLayout.YConstraint
= "{ConstraintExpression Type=RelativeToParent,Property=Height, Factor=0.5}"
RelativeLayout.WidthConstraint
= "{ConstraintExpression Type=RelativeToParent,Property=Width, Factor=1.0}"
RelativeLayout.HeightConstraint
= "{ConstraintExpression Type=RelativeToParent,Property=Height, Factor=0.5}"
/>
</RelativeLayout>
</ContentPage.Content>
</ContentPage>
@amay077
Copy link
Author

amay077 commented Mar 17, 2017

2017-03-17 12 35 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment