Kishan Gupta
Kishan Gupta

Reputation: 626

Include external font ttf in android project in Xamarin C#

I am developing an android app with Xamarin Studio in C# .NET. I have to use an external font (TTF) file in app. I have copied this ttf file into Assets folder. Now, how to use it in app by axml or code?

It is a Xamarin.Android application.

Please help.

Upvotes: 2

Views: 751

Answers (1)

Alex.F
Alex.F

Reputation: 6181

Like so:

var typeface = Typeface.CreateFromAsset (context.Assets, fileName);

Where filename would be the name of your font, for example Roboto-Light.ttf and context is, well, your Context.

Upvotes: 3

Related Questions