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.

5
  • stackoverflow.com/questions/2888508/… Commented Jun 28, 2017 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 Commented Jun 28, 2017 at 18:39
  • 1
    Possible duplicate of How to change the font on the TextView? Commented Jun 28, 2017 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! Commented Jun 28, 2017 at 19:47
  • @GrayCygnus Will do. Thank you for pointing out! Commented Jun 28, 2017 at 20:09

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.