Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set Font for TextView in android? [duplicate]

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.

like image 577
Panache Avatar asked Jun 07 '11 20:06

Panache


1 Answers

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

Typeface tf = Typeface.createFromAsset(getAssets(),
            "fonts/Arial.otf");
TextView tv = (TextView) findViewById(R.id.CustomFontText);
tv.setTypeface(tf)
like image 176
ferostar Avatar answered Oct 21 '22 22:10

ferostar