1. font 放在assets裡面:
Typeface type= Typeface.createFromAsset(getAssets(),"fonts/myFont.ttf");
textView=(TextView) findViewById(R.id.main_textview);
textView.setTypeface(type);
2. font 放在SD記憶卡:
Typeface type= Typeface.createFromFile(new File(Environment.getExternalStorageDirectory(), "/assets/fonts/myFont.ttf"));
textView=(TextView) findViewById(R.id.main_textview);
textView.setTypeface(type);
在 AndroidManifest.xml 中增加權限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
今天幫客戶做多國語的時候,在 Typeface 的地方閃退,
最後才發現竟然是忘了放自定義字體到 fonts 底下 XD,
真不知道在瞎忙什麼 Orz...