【发布时间】:2012-08-21 20:11:11
【问题描述】:
我一直在使用Jake Wharton's ViewPagerIndicator,目前我正在尝试在我的一个片段上实现自定义字体。我试过使用这段代码:
TextView txt = (TextView) findViewById(R.id.Zipcode);
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/customfont.ttf");
txt.setTypeface(font);
在主要活动的onCreate 中导致logcat 中出现空指针异常,偶尔typeface cannot be made。我还尝试在onCreate 和onCreateView 中设置片段本身的字体,但是findViewById 和getAssests() 是片段范围内的未知方法。
我无法确定字体是问题还是我尝试设置字体的位置是问题。
【问题讨论】:
-
customfont.ttf在assets/fonts/中吗? -
@kcoppock 正确我在资产/字体中有它
标签: android fonts android-fragments