Skip to content Skip to sidebar Skip to footer

Android, How To Display Font Awesome Icons In Layout Edit Mode?

I'm trying to add font awesome icons into my Android App, i found a solution here: https://stackoverflow.com/a/15762875/535556 But it display icons only after compilation of app an

Solution 1:

Make sure your ttf is in /src/main/assets/font/fontawesome.ttf (or whatever it's named, make sure it's all lower case though) Also verify that in your .iml file the assets directory matches this:


<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />.


once that is all in place then go to view where you will be displaying the icon (not the xml file, but the .java file) and in the onCreate() method or whichever you think is best, create a typeface using the fontawesome.ttf and assign it to your icon TextView, Button, or whatever visual element you want, like this:


publicstaticfinalStringFONT_AWESOME_PATH="fonts/fontawesome.ttf";
private TextView leftEyeEditIcon;

leftEyeEditIcon = (TextView) findViewById(R.id.edit_icon);
leftEyeEditIcon.setTypeface(Typeface.createFromAsset(getResources().getAssets(), FONT_AWESOME_PATH));

You can then adjust the size of the icon by going into the xml.file and setting the TextSize, since this is technically a "font".

Post a Comment for "Android, How To Display Font Awesome Icons In Layout Edit Mode?"