如何在导航栏Xamarin.forms的中心设置标题

问题描述 投票:1回答:1

如何将标题设置到导航栏的中心。我们可以不使用自定义渲染进行设置吗?我用过

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toolbar Title" android:layout_gravity="center" android:id="@+id/toolbar_title" /> 

但是它不起作用

xaml xamarin.forms
1个回答
0
投票

这是新的NavigationPage.TitleView的一种变态方式-默认情况下,Android似乎为后退按钮保留了标题视图的一部分,因此您可以设置一个偏移左边保留区域的边距:

<ContentPage>
    <NavigationPage.TitleView>
        <StackLayout>
            <Label Text="More Text" TextColor="White" HorizontalTextAlignment="Center" FontSize="20" Margin="0, 0, 75, 0" />
        </StackLayout>
    </NavigationPage.TitleView>
        ...
© www.soinside.com 2019 - 2024. All rights reserved.