package com.deyi.deyijia.widget;
import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* <p/>
* 作者:on 2016/1/19 11:19
* <p/>
* 邮箱:
* <p/>
*/
public class TypefaceTextView extends TextView {
public TypefaceTextView(Context context) {
super(context);
init(context);
}
public TypefaceTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public TypefaceTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
private void init(Context context) {
AssetManager assetManager = context.getAssets();
Typeface typeface = Typeface.createFromAsset(assetManager, "fonts/fzzy.ttf");
setTypeface(typeface);
}
}
这样写了之后,在xml里面调用。运行之后,界面会很卡。有人说用单例什么的。你们有什么更好的办法呢