【发布时间】:2017-04-26 07:52:41
【问题描述】:
我有 Xamarin Forms 应用程序。我的页面底部应该是这样的:
目前看起来是这样的:
问题是 StackLayout 不会扩展以填充空间。这是我的 xaml:
<StackLayout Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="End" Spacing="0" >
<Grid ColumnSpacing="0" RowSpacing="0" HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40" />
</Grid.RowDefinitions>
<StackLayout HorizontalOptions="CenterAndExpand" Grid.Column="0" Grid.Row="1" BackgroundColor="Blue" >
<Label Text="First" TextColor="#FFFFFF" HorizontalOptions="CenterAndExpand" />
</StackLayout>
<StackLayout HorizontalOptions="CenterAndExpand" Grid.Column="1" Grid.Row="1" BackgroundColor="Red" >
<Label Text="Second" TextColor="#FFFFFF" HorizontalOptions="CenterAndExpand" />
</StackLayout>
</Grid>
</StackLayout>
如何在 Grid 中展开 StackLayout?我希望蓝色和红色的背景在中间接触。
【问题讨论】:
-
您是否尝试在列定义中将
33.3*设置为宽度?50*两列? -
是的。它给出了相同的结果。
-
并从元素中删除
CenterAndExpand? -
是的。它也给出了相同的结果。
标签: xamarin xamarin.forms