问题描述
目前,我将这两个按钮彼此重叠
不幸的是,Visual Studio不支持Xamarin中的可视化编辑,因此我必须手动编辑XAML代码,这很难做到
有人可以帮我弄清楚如何使这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:Customrenderer;assembly=Customrenderer"
x:Class="Customrenderer.MapPage">
<StackLayout Margin="0,0">
<Button Text="Add items" Clicked="OnAddItemsClicked"/>
<Button Text="Add other" Clicked="OnAddOtherClicked"/>
<local:CustomMap x:Name="customMap"
MapType="Street" />
</StackLayout>
</ContentPage>
解决方法
使用嵌套的水平StackLayout
<StackLayout Margin="0,0">
<StackLayout Orientaion="Horizontal">
<Button Text="Add items" Clicked="OnAddItemsClicked"/>
<Button Text="Add other" Clicked="OnAddOtherClicked"/>
</StackLayout>
<local:CustomMap x:Name="customMap"
MapType="Street" />
</StackLayout>
或Grid
<Grid ColumnDefinitions="1*,1*" RowDefinitions="1*,Auto">
<Button Grid.Row="0" Grid.Column="0" Text="Add items" Clicked="OnAddItemsClicked"/>
<Button Grid.Row="0" Grid.Column="1" Text="Add other" Clicked="OnAddOtherClicked"/>
<local:CustomMap x:Name="customMap" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
MapType="Street" />
</Grid>