android设置第三方字体

来源:互联网 发布:王珊数据库第四版答案 编辑:程序博客网 时间:2024/05/18 03:01
如果font已经放在工程的assets目录中,这样改代码:

  Typeface type= Typeface.createFromAsset(getAssets(),"fonts/hwxk.ttf");
tv=(TextView) findViewById(R.id.index_grid_detail_text);
tv.setTypeface(type);


从SD卡中自定义字体:

  Typeface type= Typeface.createFromFile(new File(Environment.getExternalStorageDirectory(), "/assets/fonts/hwxk.ttf"));
tv=(TextView) findViewById(R.id.index_grid_detail_text);
tv.setTypeface(type);


0 0