public static void initCustomFont(TextView view, AttributeSet attributeSet,
@StyleableRes int[] attrs, int attrIndex) {
TypedArray typedArray = view.getContext().getTheme()
.obtainStyledAttributes(attributeSet, attrs, 0, 0);
try {
int fontIndex = typedArray.getInt(attrIndex, DEFAULT_FONT);
String fontPath = FONTS.get(fontIndex);
if (fontPath != null) {
view.setTypeface(Typeface.createFromAsset(view.getContext().getAssets(), fontPath));
} else {
throw new IllegalArgumentException("invalid font path");
}
} finally {
typedArray.recycle();
}
}
FontViewHelper.java 文件源码
java
阅读 37
收藏 0
点赞 0
评论 0
项目:openwebnet-android
作者:
评论列表
文章目录