Android代码设置字体,两个存放资源方式
作者:
wenju | 来源:发表于
2021-03-17 14:53 被阅读0次
1.res中font目录
TextView txtNormal = (TextView) findViewById(R.id.txt_helvetica);
Typeface typeface = ResourcesCompat.getFont(this, R.font.test_ttf);
txtNormal.setTypeface(typeface);
2.Assets及fonts目录
TextView txtNormal = (TextView) findViewById(R.id.txt_helvetica);
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/test_ttf.ttf");
txtNormal.setTypeface(typeface);
本文标题:Android代码设置字体,两个存放资源方式
本文链接:https://www.haomeiwen.com/subject/tdcecltx.html
网友评论