CalligraphyUtils.java 文件源码

java
阅读 36 收藏 0 点赞 0 评论 0

项目:DownloadableCalligraphy 作者:
/**
 * Tries to pull the Custom Attribute directly from the TextView.
 *
 * @param context     Activity Context
 * @param attrs       View Attributes
 * @param attributeId if -1 returns null.
 * @return null if attribute is not defined or added to View
 */
@FontRes
static int pullFontPathFromView(Context context, AttributeSet attrs, int[] attributeId) {
    if (attributeId == null || attrs == null)
        return 0;

    final String attributeName;
    try {
        attributeName = context.getResources().getResourceEntryName(attributeId[0]);
    } catch (Resources.NotFoundException e) {
        // invalid attribute ID
        return 0;
    }

    final int stringResourceId = attrs.getAttributeResourceValue(null, attributeName, -1);
    return stringResourceId > 0
            ? stringResourceId
            : attrs.getAttributeIntValue(null, attributeName, 0);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号