2016-06-16 76 views
3

我正在開發一個Xamarin Forms的Android應用程序。頁面文件是在XAML中創建的。但標題字體屬性更改不可用。我的代碼是:如何在Xamarin表單中設置PageTiltle的FontFamily和大小Android

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
     x:Class="MasterDetailPageNavigation.ContactsPage" 
     Title="Home" 
     BackgroundColor="#ff6600"> 
     <ContentPage.Content> 
      <StackLayout Padding="110,190,100,80"> 
      <Button BackgroundColor="Transparent" TextColor="White" Image="Button.png"/> 
    <StackLayout Padding="25"> 
    <Label Text="Button" TextColor="#ffffff" FontSize="Small"></Label> 
    </StackLayout> 
</StackLayout> 
</ContentPage.Content> 

如何更改標題Fontstyle?

+0

你談論的動作條/工具欄標題線下? – jzeferino

+0

[推薦頁](https://developer.android.com/training/appbar/index.html?hl=ja)這些鏈接名爲**表格** .. –

+0

http://stackoverflow.com/questions/12897071/how-to-change-titles-titles-title-text-on-action-bar –

回答

1

能否請你在你的MainActivity.cs試試這個LoadApplication(new App());

var spannableString = new SpannableString(SupportActionBar.Title); 
spannableString.SetSpan(new TypefaceSpan("yourfont.otf"), 0, spannableString.Length(), SpanTypes.ExclusiveExclusive); 
SupportActionBar.TitleFormatted = spannableString; 
+0

哪些頭文件被添加? #error –

+0

using Android.Text;並使用Android.Text.Style; – jzeferino

+0

如果我的答案幫助你標記爲正確,請它是一個很好的stackoverflow實踐。我很感激。 – jzeferino

相關問題