如何在Android开发中使用自定义的字体库

2025年03月24日 17:42
有1个网友回答
网友(1):

Android系统默认支持三种字体,分别为:“sans”, “serif”, “monospace",除此之外还可以使用其他字体文件(*.ttf) 方法一:XML中使用android默认字体: android:typeface 方法二:在Android中可以引入其他字体,首先要将字体文件保存在assets/fonts/目录下 //得到TextView控件对象 TextView textView =(TextView)findViewById(R.id.custom);   //将字体文件保存在assets/fonts/目录下,创建Typeface对象   Typeface typeFace =Typeface.createFromAsset(getAssets(),"fonts/HandmadeTypewriter.ttf");  //使用字体   textView.setTypeface(typeFace);