Android引入外部字体源代码

TextView musicTitleView = (TextView) findViewById(R.id.music_title);
TextView musicAuthorView = (TextView) findViewById(R.id.music_author);

// font set
AssetManager mgr = context.getAssets();
Typeface regularTf = Typeface.createFromAsset(mgr, "fonts/SourceHanSansCN-Regular.ttf");
Typeface robotoTf = Typeface.createFromAsset(mgr, "fonts/Roboto-Bold.ttf");
musicTitleView.setTypeface(robotoTf);
musicAuthorView.setTypeface(regularTf);

字体新建assets,font文件路径,如图

Android引入外部字体源代码_第1张图片

你可能感兴趣的:(Android)