Fay*_*yze 4 xaml xamarin xamarin.forms
我的Xamarin.Forms项目中有一个页面,我需要看起来像这样:
我可以放置红色和蓝色框,没问题。但是我不知道如何创建绿色的。
我使用的XAML如下:
<StackLayout HorizontalOptions="FillAndExpand">
<StackLayout VerticalOptions="FillAndExpand" BackgroundColor="Red">
//I'm thinking the green box should be positioned absolutely in here or something?
</StackLayout>
<StackLayout VerticalOptions="End" BackgroundColor="Blue">
<Grid VerticalOptions="EndAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Grid.Column="0" Text="Button" HorizontalOptions="FillAndExpand" BorderRadius="0" VerticalOptions="EndAndExpand" HeightRequest="50" TextColor="White" BackgroundColor="#85C034"></Button>
</Grid>
</StackLayout>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
这Grid是实现此行为的最佳布局控件。您可以使用*展开一行来填充,将文本标签嵌套在第一行的内容视图内,然后将第二行设置为所需的高度。
例如:
<?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:Grids"
x:Class="Grids.GridsPage">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<ContentView
BackgroundColor="Red" Grid.Row="0">
<Label TextColor="Black"
Text="Text"
Margin="0,0,0,10"
BackgroundColor="#00FF02"
VerticalOptions="End"
HorizontalOptions="Center"/>
</ContentView>
<ContentView BackgroundColor="Blue" Grid.Row="1"/>
</Grid>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3567 次 |
| 最近记录: |