简体   繁体   English

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

[英]How to set Title in center of navigation bar Xamarin.forms

How to set Title into center of Navigation Bar.如何将标题设置为导航栏的中心。 Can we set without custom render.我们可以在没有自定义渲染的情况下进行设置吗? I have used我用过

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

But Its not working但它不工作

Here's one hackish way with the new NavigationPage.TitleView - Android seems to reserve a portion of the title view for the back button by default, so you can just set a margin that offsets the left hand reserved area:这是新的 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>
        ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM