2011-06-07 69 views
8

可能重复:
how to change the font on the text view in android?如何在android中为TextView设置字体?

我尝试了很多设置字体在我的应用程序TextView的。但似乎没有办法在android中设置字体。我想通过xml为我的所有TextView设置Arial字体。我将Arial.ttf添加到我的资产中,但仍然无法在xml中设置样式。请找到我的出路。

+1

这是一个类似的问题/答案,我认为可能会有帮助:http://stackoverflow.com/questions/2888508/how-to-change-the-font-on-the-text-view-in-android – plainjimbo 2011-06-07 20:56:22

回答

23

AFAIK你不能在XML做到这一点,你必须这样做,在代码:

Typeface tf = Typeface.createFromAsset(getAssets(), 
      "fonts/Arial.otf"); 
TextView tv = (TextView) findViewById(R.id.CustomFontText); 
tv.setTypeface(tf) 
+0

感谢男士们......我明白了。 – Panache 2011-06-08 08:38:52

相关问题