Skip to content

Android使用第三方字体

字体资源文件

res/font/
        circular_pro_bold.otf
        pangmenzhegndao_2.ttf

代码中加载并使用字体

Typeface cirTf = ResourcesCompat.getFont(TachApplication.getInstance(), R.font.circular_pro_bold);
Typeface pangMenTf = ResourcesCompat.getFont(TachApplication.getInstance(), R.font.circular_pro_bold);
TextView udroneTv = root.findViewById(R.id.udrone_tv);
TextView umlTv = root.findViewById(R.id.uml_tv);
udroneTv.setTypeface(cirTf);
umlTv.setTypeface(cirTf);
mUserFeedbackTv.setTypeface(pangMenTf);

参考

https://stackoverflow.com/questions/27588965/how-to-use-custom-font-in-a-project-written-in-android-studio