Created
March 17, 2017 03:34
-
-
Save amay077/5ae0255b3e16f4467a90e94c7ec14208 to your computer and use it in GitHub Desktop.
Xamarin.Forms で上下等間隔2分割のレイアウトを行うサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
Author
amay077
commented
Mar 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment