2
votes

I created a grid of TextViews. It works but I would like to change the font of the TextViews (trying to use font awesome).

TextView created by following https://developer.xamarin.com/guides/android/user_interface/grid_view/

EDIT: (Solution) In the GetView() method in the link, I created a TextView named textview instead of an ImageView. In order to change the font I used the following:

Typeface typeface = Typeface.CreateFromAsset(Application.Context.Assets, "Fonts/FontAwesome.ttf"); textview.SetTypeface(typeface, TypefaceStyle.Normal);

Line 0 is different than the traditional, ypeface typeface = Typeface.CreateFromAsset(Assets, "Fonts/FontAwesome.ttf");

I needed to add Application.Context in front of Assets.

1
@wick.ed For future reference, please mark duplicates using the Flag option and selecting a duplicate..., as this automatically posts a comment on your behalf indicating the duplicate and also helps reviewers and moderators determine if it is a duplicate indeedDarkCygnus
@GrayCygnus Sorta of. I wasn't sure how to access the Assets folder since this did not implement from an Activity. The main solution I was looking for was to have Application.Context. Assets, rather than just Assets. Thank you though!srian
@GrayCygnus Will do. Thank you for pointing out!wick.ed

1 Answers

0
votes

In the GetView() method in the link, I created a TextView named textview instead of an ImageView. In order to change the font I used the following:

Typeface typeface = Typeface.CreateFromAsset(Application.Context.Assets, "Fonts/FontAwesome.ttf"); textview.SetTypeface(typeface, TypefaceStyle.Normal);

Line 0 is different than the traditional, ypeface typeface = Typeface.CreateFromAsset(Assets, "Fonts/FontAwesome.ttf");

I needed to add Application.Context in front of Assets.