如何在Xamarin表单Android中设置PageTiltle FontFamily和Size

时间:2016-06-16 11:18:32

标签: c# android xamarin xamarin.forms

我正在使用Xamarin Forms开发Android Apllication。页面文件在XAML中创建。但Title Font属性更改不可用。我的代码是:

INSERT INTO [ProjectManagement].[dbo].[Groups] 
                    (Name,          Description, Priority ,CreatorId, InsertDate, IsDeleted) 
           SELECT Bezeich, cast(Notiz as ntext),      Prio,        1,  GETDATE(), 0 
           FROM [MigrationAPlanDB].[dbo].[Ordner]

INSERT INTO [ProjectManagement].[dbo].[Projects] 
                      (Name, Description,         UpdateDate, CreatorId, InsertDate) 
           SELECT p.Bezeich,     p.Notiz, p.LastModification,         1, GETDATE() 
           FROM   [MigrationAPlanDB].[dbo].[Projekte] p 
           JOIN   [MigrationAPlanDB].[dbo].[Ordner]   o on p.Ord_Id = o.Ord_Id

如何更改Title Fontstyle?

2 个答案:

答案 0 :(得分:1)

您可以在MainActivity.cs

行下方的LoadApplication(new App());中试试这个
var spannableString = new SpannableString(SupportActionBar.Title);
spannableString.SetSpan(new TypefaceSpan("yourfont.ttf"), 0, spannableString.Length(), SpanTypes.ExclusiveExclusive);
SupportActionBar.TitleFormatted = spannableString;

答案 1 :(得分:0)

从此answer开始,然后在ContentPage中添加:

<NavigationPage.TitleView>
    <Label VerticalOptions="Center" MaxLine="1" FontFamily="/*OUR FONT GOES HERE*/" Text="Our new title" />
</NavigationPage.TitleView>

或:

<Shell.TitleView>
   <Label VerticalOptions="Center" MaxLine="1" FontFamily="/*OUR FONT GOES HERE*/" Text="Our new title" />
</Shell.TitleView>