Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Xamarin Forms - Android 10 headline font style support

YashThakurYashThakur Member ✭✭

Android 10 introduced different font styles for headline/body where headline font is different & body font is different
In xamarin forms when using android 10, my device has that fonts on Toolbar title, button text & maybe in more places.
I just wanted to set that property to my labels in some places how do I do that
Here are some samples..
https://drive.google.com/drive/folders/18fmLQ-dILSk1Xsc7ucGmv8FXq-AIKcfn?usp=sharing

As I said, the headline fonts are automatically applied to Toolbar Title & Buttons.
I just want use that fonts in some places like frame title or other places in xaml

How do I do that?

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    When you set the Font Style on Android 10, then the entire font style of the system will change.

    Of course, if you set the font style in your app , then the font you set in some places in your app will be the font style you set. For this, you can check the official document Fonts in Xamarin.Forms

    1.Set the font in code
    We can use the three font-related properties of any controls that display text:

    • FontFamily – the string font name.
    • FontSize – the font size as a double.
    • FontAttributes – a string specifying style information like Italic and Bold (using the FontAttributes enumeration in C#).

    2.Font size

    The FontSize property can be set to a double value, for instance:

     label.FontSize = 24;
    

    Besides, you can also use a custom font,custom fonts can be added to your Xamarin.Forms shared project and consumed by platform projects without any additional work.

    For more detail, you can check:https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/fonts#use-a-custom-font

Sign In or Register to comment.