0
我使用自定义字体在我的应用程序 所以我用下面的代码设置自定义字体
public class BrandonBlackTextView extends TextView {
public BrandonBlackTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public BrandonBlackTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public BrandonBlackTextView(Context context) {
super(context);
init();
}
public void init() {
Typeface tf = Typeface.createFromAsset(getContext().getAssets(), "font/brandon_blk.ttf");
setTypeface(tf ,1);
}
地方我想用我用这个textview
到TextView的。有用。 但问题有时我不知道为什么,但textview
里面的文字变成加粗。我不知道为什么会发生这种情况。这非常不一致,每次都不会发生。
如何缓存字体? –
@ShreshivasChikati加载一次,并保留一个参考。 – Karakuri
ok,但int flags = getPaintFlags()| Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG; setPaintFlags(flags);没有帮助我 –