Wednesday, March 9, 2016

Android font and caligraphy



So if you want to set an external font to a text view, you have different options:

- A common step: Get the font and put it under assets/fonts folder (create it if it not already created)

1 - Use this Gist:
Typeface typeface = Typeface.createFromAsset(getAssets(),"Roboto-Regular.ttf");
TextView textview = (TextView) findViewById(R.id.textview);
textview.setTypeface(typeface); 
2 - Use DataBinding Lib as described in here: fontbinding
3- Use XML attributes through custom widget: this is a good blog covering it all Custom fonts

No comments: