在android开发中添加外挂字体

时间:2023-03-09 16:49:01
在android开发中添加外挂字体

1.在项目目录中,右键app——New——Folder—— Assets Folder

2.把.ttf或者.oft文件拷进这个assets文件夹

3.在onCreate()中

Typeface typeface = Typeface.createFromAsset(getAssets(), "TpldKhangXiDictTrial.otf");//加入外挂字体
Button button = (Button)findViewById(R.id.button_start);
button.setTypeface(typeface);

搞定~