As per https://stackoverflow.com/a/13329907/3286489, we could change the fontFamily of the TextView. But how could I set that using Java code? I can't find the API.
Asked
Active
Viewed 604 times
0
-
if you wants to change the fontTypeFace of textview specifically the you may provide a style attribute to TextView type at styles document and add the font family to that, after that you dont need to setTypeFace to any of the textview. – Ankush Bist Jun 14 '16 at 04:48
-
Found my answer through http://stackoverflow.com/a/14344132/3286489 – Elye Jun 14 '16 at 07:11
1 Answers
1
You can use the setTypeface()
method on TextView
in java code .
Typeface font = Typeface.createFromAsset( getAssets(), "fonts/fontawesome-webfont.ttf" );
TextView tv = (TextView)findViewById(R.id.textview1);
tv.setTypeface(font);
Please visit the API link
Hope you got your answer !!!

Naveen Tamrakar
- 3,349
- 1
- 19
- 28

prashant0205
- 269
- 1
- 3
- 17
-
Almost there, the better answer is in http://stackoverflow.com/a/14344132/3286489 – Elye Jun 14 '16 at 07:11
-
@Elye Would suggest to use `createFromAsset()` and not `()` as it is more efficient and saves from you from using extraneous memory... :) .. – prashant0205 Jun 14 '16 at 07:20
-