2

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.

srian
  • 181
  • 8
  • https://stackoverflow.com/questions/2888508/how-to-change-the-font-on-the-textview – wick.ed Jun 28 '17 at 15:41
  • @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 indeed – DarkCygnus Jun 28 '17 at 18:39
  • 1
    Possible duplicate of [How to change the font on the TextView?](https://stackoverflow.com/questions/2888508/how-to-change-the-font-on-the-textview) – DarkCygnus Jun 28 '17 at 18:39
  • @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 Jun 28 '17 at 19:47
  • @GrayCygnus Will do. Thank you for pointing out! – wick.ed Jun 28 '17 at 20:09

1 Answers1

0

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.

srian
  • 181
  • 8