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

作者: RustFisher
联系: rf.cs@foxmail.com
博客: rustfisher.com | RustFisher cnblog
示例: AndroidTutorial Gitee, Tutorial Github
链接: https://www.an.rustfisher.com/android/resource/font/app-use-other-font/
一家之言,仅当抛砖引玉。如有错漏,还请指出。