android给Button或TextView等设置字体

来源:互联网 发布:ipv4 6无网络访问权限 编辑:程序博客网 时间:2024/04/29 16:27

mTypeface = Typeface.createFromAsset(context.getAssets(),"fonts/GOTHIC.TTF");

在assets文件夹是新建一个fonts文件 夹,并在里面放入ttf格式的字体文件,通过上面的语句得到字体


通过setTypeface()方法设置字体。

mTextView.setTypeface(mTypeface);