AssetManager mgr=getAssets();
Typeface tf=Typeface.createFromAsset(mgr, "fonts/cube.ttf");
textView.setTypeface(tf);
上面的方法可以修改TextView的字体,但我不想这样做。我的想法:用户可以在互联网上下载字体并将其存储在SD卡中。然后,用户可以将刚刚下载的字体应用于窗口小部件。我觉得这种方法可以减少项目的规模。有什么建议吗?
答案 0 :(得分:1)
1。)通过互联网将“font.ttf”(替换为您的ttf文件名)文件下载到外部存储。
2。)这样做。
Typeface typeface = Typeface.createFromFile(
new File(Environment.getExternalStorageDirectory(), "font.ttf"));
textView.setTypeface(tf);