helper method to get the color by attr (which is defined in the style) or by resource.

@param ctx
@param attr
@param res
@return
978139
public static int getThemeColorFromAttrOrRes(Context ctx, @AttrRes int attr, @ColorRes int res) {
        int color = getThemeColor(ctx, attr);
        if (color == 0) {
            color = ResourcesCompat.getColor(ctx.getResources(), res, ctx.getTheme());
        }
        return color;
    }
775383
public int getIconColor(Context ctx) {
        int iconColor;
        if (this.isEnabled()) {
            iconColor = ColorHolder.color(getIconColor(), ctx, R.attr.material_drawer_primary_icon, R.color.material_drawer_primary_icon);
        } else {
            iconColor = ColorHolder.color(getDisabledIconColor(), ctx, R.attr.material_drawer_hint_icon, R.color.material_drawer_hint_icon);
        }
        return iconColor;
    }
604400
function(anim, att) {
        var node = anim._node,
            val = '';

        if (att in node._node.style || att in Y.DOM.CUSTOM_STYLES) {
            val = node.getComputedStyle(att);
        } else if (node._node.attributes[att]) {
            val = node.getAttribute(att);
        } else {
            val = node.get(att);
        }

        return val;
    }
31606
def _set_attr(self, attr):
        
        if attr in text:
            self._text_attr(attr)
        elif attr in colors["foreground"]:
            self._color_attr("foreground", attr)
        elif attr in colors["background"]:
            self._color_attr("background", attr)
1261768
@SuppressWarnings("deprecation")
    public static @ColorInt int resolveColor(@ColorRes int color, Context context) {
        if (Build.VERSION.SDK_INT >= 23) {
            return context.getResources().getColor(color, context.getTheme());
        }
        else {
            return context.getResources().getColor(color);
        }
    }
1170435
public static Color stringToColor(String str) {
    int icol = SVG_COLOR_NAMES.getInt(str.toLowerCase());
    if(icol != NO_VALUE) {
      return new Color(icol, false);
    }
    return colorLookupStylesheet.stringToColor(str);
  }
370207
private boolean isActivityThemeLight() {
        try {
            TypedValue val = new TypedValue();

            //Reading attr value from current theme
            getActivity().getTheme().resolveAttribute(R.attr.isLightTheme, val, true);

            //Passing the resource ID to TypedArray to get the attribute value
            TypedArray styledAttributes =
                    getActivity().obtainStyledAttributes(val.data, new int[]{R.attr.isLightTheme});
            boolean lightTheme = styledAttributes.getBoolean(0, false);
            styledAttributes.recycle();

            return lightTheme;
        } catch (RuntimeException e) {
            //Resource not found , so sticking to light theme
            return true;
        }
    }
634953
def background_color_attribute(styles={})
      return nil if styles.nil?
      value = styles[:background_color]
      return nil unless value && value.is_a?(UIColor)
      value
    end
1270953
public void setupStyleable(Context context, AttributeSet attrs) {
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RoundCornerProgress);

        radius = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcRadius, dp2px(DEFAULT_PROGRESS_RADIUS));
        padding = (int) typedArray.getDimension(R.styleable.RoundCornerProgress_rcBackgroundPadding, dp2px(DEFAULT_BACKGROUND_PADDING));

        isReverse = typedArray.getBoolean(R.styleable.RoundCornerProgress_rcReverse, false);

        max = typedArray.getFloat(R.styleable.RoundCornerProgress_rcMax, DEFAULT_MAX_PROGRESS);
        progress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcProgress, DEFAULT_PROGRESS);
        secondaryProgress = typedArray.getFloat(R.styleable.RoundCornerProgress_rcSecondaryProgress, DEFAULT_SECONDARY_PROGRESS);

        int colorBackgroundDefault = context.getResources().getColor(R.color.round_corner_progress_bar_background_default);
        colorBackground = typedArray.getColor(R.styleable.RoundCornerProgress_rcBackgroundColor, colorBackgroundDefault);
        int colorProgressDefault = context.getResources().getColor(R.color.round_corner_progress_bar_progress_default);
        colorProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcProgressColor, colorProgressDefault);
        int colorSecondaryProgressDefault = context.getResources().getColor(R.color.round_corner_progress_bar_secondary_progress_default);
        colorSecondaryProgress = typedArray.getColor(R.styleable.RoundCornerProgress_rcSecondaryProgressColor, colorSecondaryProgressDefault);
        typedArray.recycle();

        initStyleable(context, attrs);
    }
638432
public Object getattr(String attr) throws PickleException, PyroException, IOException {
		return this.internal_call("__getattr__", null, 0, false, attr);
	}
730315
@Nullable
    public static IconicsDrawable getIconicsImageViewDrawable(@NonNull Context ctx,
                                                              @Nullable AttributeSet attrs) {
        final TypedArray a = ctx.obtainStyledAttributes(attrs, R.styleable.IconicsImageView);
        try {
            return new IconicsAttrsExtractor(ctx, a)
                    .iconId(R.styleable.IconicsImageView_iiv_icon)
                    .colorsId(R.styleable.IconicsImageView_iiv_color)
                    .sizeId(R.styleable.IconicsImageView_iiv_size)
                    .paddingId(R.styleable.IconicsImageView_iiv_padding)
                    .contourColorId(R.styleable.IconicsImageView_iiv_contour_color)
                    .contourWidthId(R.styleable.IconicsImageView_iiv_contour_width)
                    .backgroundColorId(R.styleable.IconicsImageView_iiv_background_color)
                    .cornerRadiusId(R.styleable.IconicsImageView_iiv_corner_radius)
                    .backgroundContourColorId(R.styleable.IconicsImageView_iiv_background_contour_color)
                    .backgroundContourWidthId(R.styleable.IconicsImageView_iiv_background_contour_width)
                    .shadowRadiusId(R.styleable.IconicsImageView_iiv_shadow_radius)
                    .shadowDxId(R.styleable.IconicsImageView_iiv_shadow_dx)
                    .shadowDyId(R.styleable.IconicsImageView_iiv_shadow_dy)
                    .shadowColorId(R.styleable.IconicsImageView_iiv_shadow_color)
                    .animationsId(R.styleable.IconicsImageView_iiv_animations)
                    .extract();
        } finally {
            a.recycle();
        }
    }
422670
def is_resource_class_resource_attribute(rc, attr_name):
    
    attr = get_resource_class_attribute(rc, attr_name)
    return attr != RESOURCE_ATTRIBUTE_KINDS.TERMINAL
237102
private int obtainTheme() {
        TypedArray typedArray =
                getContext().getTheme().obtainStyledAttributes(new int[]{R.attr.toolbarTheme});
        return typedArray.getResourceId(0, 0);
    }
22787
public static int getThemeColor(Context ctx, @AttrRes int attr) {
        TypedValue tv = new TypedValue();
        if (ctx.getTheme().resolveAttribute(attr, tv, true)) {
            return tv.resourceId != 0 ? ContextCompat.getColor(ctx, tv.resourceId) : tv.data;
        }
        return 0;
    }
95571
function getCss(elem, attr) {
    const val = win.getComputedStyle(elem)[attr];

    // 对于属性值是 200px 这样的形式，返回 200 这样的数字值
    return regExp.styleValue.test(val) ? pInt(val) : val;
}
730707
def get_attr(self, name, default=None, fail_silently=True):
        
        try:
            return getattr(self, name)
        except KeyError:
            extra_context = getattr(self, "extra_context")

            if name in extra_context:
                value = extra_context[name]

                if callable(value):
                    return value(request=None)

            return default
242499
public int color(Context ctx, @AttrRes int colorStyle, @ColorRes int colorDefaultRes) {
        //get the color from the holder else from the theme
        int color = color(ctx);
        if (color == 0) {
            return UIUtils.getThemeColorFromAttrOrRes(ctx, colorStyle, colorDefaultRes);
        } else {
            return color;
        }
    }