Home » Android » How to set Font for TextView in android?

How to set Font for TextView in android?

Posted by: admin June 15, 2020 Leave a comment


Possible Duplicate:
how to change the font on the text view in android?

I tried a lot to set font for the TextView in my app. But there is no way seems to set font in android. I want to set Arial font for all of my TextView through xml. I added Arial.ttf to my assets still unable to set style in xml. Please find me a way out.

How to&Answers:

AFAIK you can’t do it in xml, you have to do it in code:

Typeface tf = Typeface.createFromAsset(getAssets(),
TextView tv = (TextView) findViewById(R.id.CustomFontText);