自定义字体问题,麻烦看看。谢谢

怀君 2016-04-01 09:01:17
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里面调用。运行之后,界面会很卡。有人说用单例什么的。你们有什么更好的办法呢
...全文
212 1 打赏 收藏 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
怀君 2016-04-01
  • 打赏
  • 举报
回复
不能沉啊 兄弟们

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧