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.
2
-
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– Ankush Bist2016-06-14 04:48:26 +00:00Commented Jun 14, 2016 at 4:48
-
Found my answer through stackoverflow.com/a/14344132/3286489Elye– Elye2016-06-14 07:11:29 +00:00Commented Jun 14, 2016 at 7:11
Add a comment
|
1 Answer
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 !!!
3 Comments
Elye
Almost there, the better answer is in stackoverflow.com/a/14344132/3286489
prashant0205
@Elye Would suggest to use
createFromAsset() and not () as it is more efficient and saves from you from using extraneous memory... :) ..prashant0205
I meant not
create()