• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FontRes类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中android.support.annotation.FontRes的典型用法代码示例。如果您正苦于以下问题:Java FontRes类的具体用法?Java FontRes怎么用?Java FontRes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FontRes类属于android.support.annotation包,在下文中一共展示了FontRes类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: pullFontPathFromView

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:27,代码来源:CalligraphyUtils.java


示例2: pullFontPathFromStyle

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * Tries to pull the Font Path from the View Style as this is the next decendent after being
 * defined in the View's xml.
 *
 * @param context     Activity Activity Context
 * @param attrs       View Attributes
 * @param attributeId if -1 returns null.
 * @return null if attribute is not defined or found in the Style
 */
@FontRes
static int pullFontPathFromStyle(Context context, AttributeSet attrs, int[] attributeId) {
    if (attributeId == null || attrs == null)
        return 0;
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, attributeId);
    if (typedArray != null) {
        try {
            // First defined attribute
            int fontFromAttribute = typedArray.getResourceId(0, 0);
            if (fontFromAttribute != 0) {
                return fontFromAttribute;
            }
        } catch (Exception ignore) {
            // Failed for some reason.
        } finally {
            typedArray.recycle();
        }
    }
    return 0;
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:30,代码来源:CalligraphyUtils.java


示例3: pullFontPathFromTextAppearance

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * Tries to pull the Font Path from the Text Appearance.
 *
 * @param context     Activity Context
 * @param attrs       View Attributes
 * @param attributeId if -1 returns null.
 * @return returns null if attribute is not defined or if no TextAppearance is found.
 */
@FontRes
static int pullFontPathFromTextAppearance(final Context context, AttributeSet attrs, int[] attributeId) {
    if (attributeId == null || attrs == null)
        return 0;
    int textAppearanceId = -1;
    // For prevent using default component font
    final ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, android.R.style.Theme_NoDisplay);
    final TypedArray typedArrayAttr = contextThemeWrapper.obtainStyledAttributes(attrs, ANDROID_ATTR_TEXT_APPEARANCE);
    if (typedArrayAttr != null) {
        try {
            textAppearanceId = typedArrayAttr.getResourceId(0, 0);
        } catch (Exception ignored) {
            // Failed for some reason
            return 0;
        } finally {
            typedArrayAttr.recycle();
        }
    }

    final Integer textAppearanceAttrs = getFontFromTextAppearance(context, attributeId, textAppearanceId);
    if (textAppearanceAttrs != null) return textAppearanceAttrs;
    return 0;
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:32,代码来源:CalligraphyUtils.java


示例4: pullFontPathFromTheme

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * Last but not least, try to pull the Font Path from the Theme, which is defined.
 *
 * @param context     Activity Context
 * @param styleAttrId Theme style id
 * @param attributeId if -1 returns null.
 * @return null if no theme or attribute defined.
 */
@FontRes
static int pullFontPathFromTheme(Context context, int styleAttrId, int[] attributeId) {
    if (styleAttrId == -1 || attributeId == null)
        return 0;

    final Resources.Theme theme = context.getTheme();
    final TypedValue value = new TypedValue();

    theme.resolveAttribute(styleAttrId, value, true);
    final TypedArray typedArray = theme.obtainStyledAttributes(value.resourceId, attributeId);
    try {
        return typedArray.getResourceId(0, 0);
    } catch (Exception ignore) {
        // Failed for some reason.
        return 0;
    } finally {
        typedArray.recycle();
    }
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:28,代码来源:CalligraphyUtils.java


示例5: getDefaultTypeface

import android.support.annotation.FontRes; //导入依赖的package包/类
private Typeface getDefaultTypeface(Context context, @FontRes int fontFamily) {
    if (fontFamily == 0) {
        fontFamily = CalligraphyConfig.get().getFontFamily();
    }
    if (fontFamily != 0) {
        return ResourcesCompat.getFont(context, fontFamily);
    }
    return null;
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:10,代码来源:CalligraphyFactory.java


示例6: setTabFont

import android.support.annotation.FontRes; //导入依赖的package包/类
private void setTabFont(int textViewId, @FontRes int font, int position) {
    if (font == 0)
        return;

    Typeface typeface = ResourcesCompat.getFont(getContext(), font);
    setTabFont(textViewId, typeface, position);
}
 
开发者ID:kristiyanP,项目名称:anotherViewPager,代码行数:8,代码来源:TabbedViewPager.java


示例7: getFontFamily

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * @return mFontFamily for text views might be null
 */
@FontRes
public int getFontFamily() {
    return mFontFamily;
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:8,代码来源:CalligraphyConfig.java


示例8: setSelectedTabFont

import android.support.annotation.FontRes; //导入依赖的package包/类
public TabbedViewPager setSelectedTabFont(@FontRes int font) {
    selectedTabFont = font;
    return this;
}
 
开发者ID:kristiyanP,项目名称:anotherViewPager,代码行数:5,代码来源:TabbedViewPager.java


示例9: CustomDownloadableFontProvider

import android.support.annotation.FontRes; //导入依赖的package包/类
public CustomDownloadableFontProvider(@FontRes int resourceFont) {
    this.resourceFont = resourceFont;
}
 
开发者ID:gonzalonm,项目名称:Downloadable-Fonts,代码行数:4,代码来源:CustomDownloadableFontProvider.java


示例10: getFontResId

import android.support.annotation.FontRes; //导入依赖的package包/类
public @FontRes int getFontResId() {
    return fontResId;
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:4,代码来源:BaselineGridTextView.java


示例11: setDefaultFont

import android.support.annotation.FontRes; //导入依赖的package包/类
/**
 * Set the default font if you don't define one else where in your styles.
 *
 * @param defaultFont a path to a font file in the assets folder, e.g. "fonts/Roboto-light.ttf",
 *                             passing null will default to the device font-family.
 * @return this builder.
 */
public Builder setDefaultFont(@FontRes int defaultFont) {
    this.isFontSet = defaultFont != 0;
    this.fontFamily = defaultFont;
    return this;
}
 
开发者ID:takahirom,项目名称:DownloadableCalligraphy,代码行数:13,代码来源:CalligraphyConfig.java


示例12: getFontResId

import android.support.annotation.FontRes; //导入依赖的package包/类
@FontRes int getFontResId(); 
开发者ID:nickbutcher,项目名称:plaid,代码行数:2,代码来源:ReflowText.java



注:本文中的android.support.annotation.FontRes类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PluginConfiguration类代码示例发布时间:2022-05-22
下一篇:
Java JavaSource类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap