开发者

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

This question already has answers here: Closed 11 years ago.

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 seem开发者_Python百科s 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.


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜