我已经创建了一个TextView库项目,我已经使用了自定义字体。我必须创建这个库,因为这个TextView
也将在其他三个项目中使用。我发现android库项目不支持assets/fonts文件夹。如果我用这种方式,它给我错误信息如何在android库项目中使用自定义字体?
native typeface cannot be made at android.graphics.Typeface
有没有什么解决方法来解决这个问题。其他方式,我必须在三个不同的应用程序中使用重复的视图。还有我用来从库资源文件夹中获取字体的示例代码。
public static Typeface getFont(Context c, String fontName) {
synchronized (fonts) {
if (!fonts.containsKey(fontName)) {
Typeface t = Typeface.createFromAsset(
c.getAssets(), "fonts" + File.separator + fontName);
fonts.put(fontName, t);
}
return fonts.get(fontName);
}
}
你能分享代码吗?你正在使用? – rockstar
在你的库中创建'assets/fonts'文件夹 –
你使用的是什么构建系统? –