2

I am developing an xamarin Android application and need to use FontAwesome icons in application. But don't know how to use it. Got lot's of articles on internet but it's not clear to me.

How to use FontAwesome icons on Xamarin.Android?

3
  • What have you tried so far, any code you have tried? There are lot of tutorials about adding font awesome to the asset folder and creating a helper class on the interweb. Commented Oct 18, 2017 at 8:57
  • Sir I have tried these 2 tutorial's tutorial 1, tutorial 2 Commented Oct 18, 2017 at 8:59
  • but as I have tried the code they have provided in these articles It showing me an error under each line of code. type or namespace could not be found(are you missing a using directive or an assembly reference?) Commented Oct 18, 2017 at 9:04

2 Answers 2

2

I have got worked as below:

Copy FontAwesome ttf file to Assets folder. Then under OnCreate() method of Activity page the control should be referred to the font file as below:

Activity Page:

Typeface font = Typeface.CreateFromAsset(Application.Assets, "fontawesome-webfont.ttf"); TextView txtv = (TextView)FindViewById(Resource.Id.textviewtitle); txtv.Typeface = font; 

.xaml Page:

<TextView android:layout_height="fill_parent" android:layout_width="wrap_content" android:editable="false" android:text="\uf238 Unicode To get FontAwesome icon" android:textSize="20dp" android:textColor="#545454" android:textStyle="bold" android:padding="6dp" android:id="@+id/textviewtitle" /> 

As you see above in .xaml Page code android:text="\uf238 Unicode To get FontAwesome icon", I have declared \uf238. This is unicode for the particular icon. Every Icon would have unique unicode. Therefore we should use always unicode character to get any icon displayed on control or on text.

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

Comments

1

Found this on web use following github repo to get Xamarin.Plugins it has

Font Awesome, Ionicons, Material design icons, Meteocons

https://github.com/jsmarcus/Xamarin.Plugins/tree/master/Iconize

9 Comments

Sir, there are lots of folders. Which folder should I have to access ?
go to following link and read readme github.com/JoanZapata/android-iconify
Sir the link that you have shared is for xamarin.Forms App. right ? I need for xamarin.Android. .
Did you go to last link I commented
android:text="I {fa-heart-o} to {fa-code} on {fa-android}" Check readme
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.