由网友(充血的你)分享简介:在我的应用程序需要使用Helvetica字体的所有textviews和编辑文本字段。有没有办法做到这一点除了使用settypeface方法对每个TextView的?任何建议将是一个很大的帮助。 In my application I need to use helvetica font for all the tex...
在我的应用程序需要使用Helvetica字体的所有textviews和编辑文本字段。有没有办法做到这一点除了使用settypeface方法对每个TextView的?任何建议将是一个很大的帮助。
In my application I need to use helvetica font for all the textviews and edit-text fields. Is there any way to do this other than using settypeface method for every textview ? Any suggestion would be a great help.
在此先感谢!
推荐答案
我想,这也使我的自我。这是code我用。我创建自定义的的TextView
具有自定义字体作为默认字体。
I figured it out by my self. This is the code I used. I create custom TextView
which has custom font as default font.
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public MyTextView(Context context) {
super(context);
init();
}
public void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "font/chiller.ttf");
setTypeface(tf ,1);
}
}
相关推荐
最新文章