关于android添加第三方字体的方法
android添加第三方字体,type=Typeface.createFromFile("@assets/fonts/hwxk.ttf");
tv=(TextView) findViewById(R.id.index_grid_detail_text);
tv.setTypeface(type);
提示 native typeface cannot be made
[最优解释]
如果font已经放在工程的assets目录中,这样改代码:
Typeface type= Typeface.createFromAsset(getAssets(),"fonts/hwxk.ttf");
tv=(TextView) findViewById(R.id.index_grid_detail_text);
tv.setTypeface(type);
Typeface type= Typeface.createFromFile(new File(Environment.getExternalStorageDirectory(), "/assets/fonts/hwxk.ttf"));
tv=(TextView) findViewById(R.id.index_grid_detail_text);
tv.setTypeface(type);
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />