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文件路徑,如圖

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章