0

I use a fontawesome-webfont.ttf font file in my assets folder.

my layout file:

<TextView
    android:id="@+id/shop_search"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="5"
    android:gravity="center"
    android:text="@string/fa_search"
    android:textColor="@color/gray"
    android:textSize="25sp" />

My string file:

 <string name="fa_hourglass">&#xf252;</string>

My java file:

itemView = (TextView) itemView.findViewById(R.id.item);
Typeface font = Typeface.createFromAsset(mContext.getAssets(), "fontawesome-webfont.ttf");
itemView .setTypeface(font);
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Gunvant Murge
  • 65
  • 1
  • 9
  • 1
    Take a look here: http://stackoverflow.com/questions/37959751/how-to-use-font-awesome-icon-in-android-application – FrankR Jan 18 '17 at 10:21

1 Answers1

0

Because in the string.xml file you have defined the string

<string name="fa_hourglass">&#xf252;</string>

But in your TextView you used the wrong string

  android:text="@string/fa_search"

so change the text to this

  android:text="@string/fa_hourglass"
Wilder Pereira
  • 2,249
  • 3
  • 21
  • 31
Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95