4

I'm developing a Android Apllication with Xamarin Forms. Page files are created in XAML. But Title Font properties changes are not available. My code is:

 <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>

How to change Title Fontstyle ?

jzeferino
  • 7,700
  • 1
  • 39
  • 59
Aboobakkar P S
  • 796
  • 1
  • 8
  • 28

2 Answers2

3

Start from this answer then in the ContentPage add:

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

or:

<Shell.TitleView>
   <Label VerticalOptions="Center" MaxLine="1" FontFamily="/*OUR FONT GOES HERE*/" Text="Our new title" />
</Shell.TitleView>
Emma
  • 27,428
  • 11
  • 44
  • 69
ElSanto079
  • 56
  • 4
1

Can you please try this in your MainActivity.cs below the line LoadApplication(new App());

var spannableString = new SpannableString(SupportActionBar.Title);
spannableString.SetSpan(new TypefaceSpan("yourfont.ttf"), 0, spannableString.Length(), SpanTypes.ExclusiveExclusive);
SupportActionBar.TitleFormatted = spannableString;
jzeferino
  • 7,700
  • 1
  • 39
  • 59