当前位置: 首页>>代码示例>>Java>>正文


Java StyleableRes类代码示例

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


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

示例1: resolveThemeColors

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@ColorInt
private static int[] resolveThemeColors(@NonNull Context context, @AttrRes @StyleableRes int[] attrs, @ColorInt int[] defaultColors) {
    if (attrs.length != defaultColors.length)
        throw new IllegalArgumentException("Argument attrs must be the same size as defaultColors");
    TypedValue typedValue = new TypedValue();

    TypedArray a = context.obtainStyledAttributes(typedValue.data, attrs);

    for (int i = 0; i < attrs.length; i++) {
        defaultColors[i] = a.getColor(0, defaultColors[i]);
    }

    a.recycle();

    return defaultColors;
}
 
开发者ID:rosenpin-deprecated,项目名称:More-For-GO,代码行数:17,代码来源:ThemeUtils.java

示例2: initCustomFont

import android.support.annotation.StyleableRes; //导入依赖的package包/类
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();
    }
}
 
开发者ID:openwebnet,项目名称:openwebnet-android,代码行数:19,代码来源:FontViewHelper.java

示例3: resolveThemeColors

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@ColorInt
private static int[] resolveThemeColors(@NonNull Context context, @AttrRes @StyleableRes int[] attrs, @ColorInt int[] defaultColors) {
    if (attrs.length != defaultColors.length)
        throw new IllegalArgumentException("Argument attrs must be the same size as defaultColors");
    TypedValue typedValue = new TypedValue();

    //noinspection ResourceType
    TypedArray a = context.obtainStyledAttributes(typedValue.data, attrs);

    for (int i = 0; i < attrs.length; i++) {
        defaultColors[i] = a.getColor(0, defaultColors[i]);
    }

    a.recycle();

    return defaultColors;
}
 
开发者ID:karnikram,项目名称:the-ssn-app,代码行数:18,代码来源:ThemeUtils.java

示例4: initPrevState

import android.support.annotation.StyleableRes; //导入依赖的package包/类
private ToolbarState initPrevState(Toolbar toolbar) {
    ToolbarState prevState = new ToolbarState();
    if (toolbar.getBackground() != null) {
        prevState.toolbarColor = ((ColorDrawable) (toolbar.getBackground())).getColor();
    }
    Context context = toolbar.getContext();
    TypedValue typedValue = new TypedValue();
    TypedArray attr = context.obtainStyledAttributes(typedValue.data,
            new int[]{R.attr.colorPrimary, R.attr.colorPrimaryDark});
    if (attr != null) {
        if (prevState.toolbarColor > 0) {
            prevState.toolbarColor = attr.getColor(0, 0);
        }
        @StyleableRes int index = 1;
        prevState.statusBarColor = attr.getColor(index, prevState.toolbarColor);
        attr.recycle();
    }

    if (toolbar.getTitle() != null) {
        prevState.title = toolbar.getTitle().toString();
    }

    if (toolbar.getSubtitle() != null) {
        prevState.subTitle = toolbar.getSubtitle().toString();
    }

    prevState.title = prevState.title != null ? prevState.title : EMPTY;
    prevState.subTitle = prevState.subTitle != null ? prevState.subTitle : EMPTY;

    prevState.logo = toolbar.getLogo();
    prevState.navigationIcon = toolbar.getNavigationIcon();


    return prevState;
}
 
开发者ID:AbyxBelgium,项目名称:Loyalty,代码行数:36,代码来源:MultiMode.java

示例5: onGlobalLayoutChange

import android.support.annotation.StyleableRes; //导入依赖的package包/类
public void onGlobalLayoutChange(@StyleableRes int headerRes, @StyleableRes int footerRes){
    int headerId = mTypedArrayResourceProvider.getResourceId(headerRes);
    if(headerId != 0) {
        mStickyScrollPresentation.initHeaderView(headerId);
    }
    int footerId = mTypedArrayResourceProvider.getResourceId(footerRes);
    if(footerId != 0){
        mStickyScrollPresentation.initFooterView(footerId);
    }
    mTypedArrayResourceProvider.recycle();
}
 
开发者ID:amarjain07,项目名称:StickyScrollView,代码行数:12,代码来源:StickyScrollPresenter.java

示例6: getDrawable

import android.support.annotation.StyleableRes; //导入依赖的package包/类
public static Drawable getDrawable(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) {
    Drawable val = a.getDrawable(index);
    if (val == null) {
        return a.getDrawable(fallbackIndex);
    }
    return val;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:TypedArrayUtils.java

示例7: getString

import android.support.annotation.StyleableRes; //导入依赖的package包/类
public static String getString(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) {
    String val = a.getString(index);
    if (val == null) {
        return a.getString(fallbackIndex);
    }
    return val;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:TypedArrayUtils.java

示例8: getTextArray

import android.support.annotation.StyleableRes; //导入依赖的package包/类
public static CharSequence[] getTextArray(TypedArray a, @StyleableRes int index, @StyleableRes int fallbackIndex) {
    CharSequence[] val = a.getTextArray(index);
    if (val == null) {
        return a.getTextArray(fallbackIndex);
    }
    return val;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:TypedArrayUtils.java

示例9: resolveColorAttributesFromTheme

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@NonNull
private static int[] resolveColorAttributesFromTheme(Context context, @StyleableRes int[] attrs) {
    final TypedArray ta = context.obtainStyledAttributes(attrs);
    final int[] colors = new int[attrs.length];
    for (int idxAttr = 0; idxAttr < colors.length; idxAttr++) {
        colors[idxAttr] = ta.getColor(idxAttr, 0);
    }
    ta.recycle();
    return colors;
}
 
开发者ID:philliphsu,项目名称:NumberPadTimePicker,代码行数:11,代码来源:NumberPadTimePickerBottomSheetComponent.java

示例10: getDimension

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@Px
static int getDimension(Context context,
                        TypedArray array,
                        @StyleableRes int attr,
                        @DimenRes int defaultDimenRes) {

    return array.getDimensionPixelOffset(
            attr, context.getResources().getDimensionPixelSize(defaultDimenRes));
}
 
开发者ID:dewarder,项目名称:CameraButton,代码行数:10,代码来源:TypedArrayHelper.java

示例11: getColor

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@ColorInt
static int getColor(Context context,
                    TypedArray array,
                    @StyleableRes int attr,
                    @ColorRes int defaultColorRes) {

    if (Build.VERSION.SDK_INT >= 23) {
        return array.getColor(attr, context.getColor(defaultColorRes));
    } else {
        return array.getColor(attr, context.getResources().getColor(defaultColorRes));
    }
}
 
开发者ID:dewarder,项目名称:CameraButton,代码行数:13,代码来源:TypedArrayHelper.java

示例12: getColors

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@ColorInt
static int[] getColors(Context context,
                       TypedArray array,
                       @StyleableRes int attr,
                       @ArrayRes int defaultColorsRes) {

    return context.getResources().getIntArray(
            array.getResourceId(attr, defaultColorsRes));
}
 
开发者ID:dewarder,项目名称:CameraButton,代码行数:10,代码来源:TypedArrayHelper.java

示例13: getInteger

import android.support.annotation.StyleableRes; //导入依赖的package包/类
static int getInteger(Context context,
                      TypedArray array,
                      @StyleableRes int attr,
                      @IntegerRes int defaultIntRes) {

    return array.getInteger(
            attr, context.getResources().getInteger(defaultIntRes));
}
 
开发者ID:dewarder,项目名称:CameraButton,代码行数:9,代码来源:TypedArrayHelper.java

示例14: FixedSizeLayout

import android.support.annotation.StyleableRes; //导入依赖的package包/类
@SuppressWarnings("ResourceType")
public FixedSizeLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    @StyleableRes int[] sizeAttrs = { android.R.attr.maxWidth, android.R.attr.maxHeight };
    TypedArray a = context.obtainStyledAttributes(attrs, sizeAttrs);
    mMaxLayoutWidth = a.getLayoutDimension(0, -1);
    mMaxLayoutHeight = a.getLayoutDimension(1, -1);
    a.recycle();
}
 
开发者ID:jruesga,项目名称:rview,代码行数:11,代码来源:FixedSizeLayout.java

示例15: loadColor

import android.support.annotation.StyleableRes; //导入依赖的package包/类
/**
 * Load the color from xml attributes or fallback to the default if not found
 *
 * @param typedArray            attributes typed array
 * @param index        the styleable index
 * @param defaultColor the default color resource id
 * @return the color to use
 */
@ColorInt
private int loadColor(TypedArray typedArray, @StyleableRes int index, @ColorRes int defaultColor) {
    int loadedColor = ContextCompat.getColor(getContext(), defaultColor);
    ColorStateList colorList = typedArray.getColorStateList(index);

    if (colorList != null) {
        loadedColor = colorList.getDefaultColor();
    }

    return loadedColor;
}
 
开发者ID:mercadopago,项目名称:px-android,代码行数:20,代码来源:MPLoadingSpinner.java


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