android如何引入第三方字体

来源:互联网 发布:儿童学编程 软件 编辑:程序博客网 时间:2024/05/21 00:16

1.下载第三方字体TTF,并在android工程目录assets下新建目录fonts,并将该TTF文件copy到该目录下。

2.在程序中加入如下代码:

Typeface fontFace = Typeface.createFromAsset(getAssets(),"fonts/huawenxinkai.ttf");
    tvWelcome = (TextView)findViewById(R.id.tv_welcome);
    tvWelcome.setTypeface(fontFace);