我有一个 StackLayout,用于在 XAML 中创建导航栏。这个水平的 StackLayout 包含一个按钮和标签。问题是文本并不完全居中,我似乎无法将其完美地放置在中间。请有人帮我将此文本居中在此 StackLayout 中吗?顺便说一下,我正在使用 Xamarin。
<!-- Nav Bar-->
<StackLayout Orientation="Horizontal" HeightRequest="45" BackgroundColor="{StaticResource Teal}">
<StackLayout.Padding>
<OnPlatform x:TypeArguments="Thickness"
iOS="10,0,0,0"
Android="0,0,0,0"
WinPhone="0,0,0,0" />
</StackLayout.Padding>
<Button x:Name="btnBack" HorizontalOptions="Start" TextColor="White" BackgroundColor="Transparent"
Command="{Binding BackCommand}" IsVisible="{Binding CanGoBack}" />
<Label HorizontalOptions="CenterAndExpand" VerticalOptions="Center" TextColor="White" FontSize="24" Text="{Binding TitleBarText}" LineBreakMode="TailTruncation" />
</StackLayout>
如您所见,应用程序标题未居中...