簡體   English   中英

如何在導航欄的中心設置標題 Xamarin.forms

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

如何將標題設置為導航欄的中心。 我們可以在沒有自定義渲染的情況下進行設置嗎? 我用過

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

但它不工作

這是新的 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