android add third-party fonts, type = Typeface.createFromFile ("@ assets / fonts / hwxk.ttf");
tv = (TextView) findViewById (R.id.index_grid_detail_text);
tv.setTypeface (type);
Tips native typeface cannot be made
Reply:
createFromFile need to specify the path to the file, right, @ assets / fonts / hwxk.ttf this count?
Try using this Typeface.createFromAsset (getAssets (), "fonts / hwxk.ttf")
Reply:
You said that method does not work. I tried. The same error
Reply:
What's on your font
Reply:
assets / fonts / qqqq.ttf
Reply:
If the font has been placed assets in the project directory, so change the code:
Typeface type = Typeface.createFromAsset (getAssets (), "fonts / hwxk.ttf");
tv = (TextView) findViewById (R.id.index_grid_detail_text);
tv.setTypeface (type);
Custom fonts from SD card:
Typeface type = Typeface.createFromFile (new File (Environment.getExternalStorageDirectory (), "/ assets / fonts / hwxk.ttf"));
tv = (TextView) findViewById (R.id.index_grid_detail_text);
tv.setTypeface (type);
Add sdcard permission AndroidManifest.xml file:
Reply:
Useful, mark it!
No comments:
Post a Comment