0

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. Commented Jun 14, 2016 at 4:48
  • Found my answer through stackoverflow.com/a/14344132/3286489 Commented Jun 14, 2016 at 7:11

1 Answer 1

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 !!!

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

3 Comments

Almost there, the better answer is in stackoverflow.com/a/14344132/3286489
@Elye Would suggest to use createFromAsset() and not () as it is more efficient and saves from you from using extraneous memory... :) ..
I meant not create()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.