use of carbon.drawable.DefaultPrimaryColorStateList in project Carbon by ZieIony.
the class Button method initButton.
private void initButton(AttributeSet attrs, int defStyleAttr) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Button, defStyleAttr, R.style.carbon_Button);
int ap = a.getResourceId(R.styleable.Button_android_textAppearance, -1);
if (ap != -1)
setTextAppearanceInternal(ap);
for (int i = 0; i < a.getIndexCount(); i++) {
int attr = a.getIndex(i);
if (attr == R.styleable.Button_carbon_textAllCaps) {
setAllCaps(a.getBoolean(R.styleable.Button_carbon_textAllCaps, true));
} else if (!isInEditMode() && attr == R.styleable.Button_carbon_fontPath) {
String path = a.getString(attr);
Typeface typeface = TypefaceUtils.getTypeface(getContext(), path);
setTypeface(typeface);
} else if (attr == R.styleable.Button_carbon_fontFamily) {
int textStyle = a.getInt(R.styleable.Button_android_textStyle, 0);
Typeface typeface = TypefaceUtils.getTypeface(getContext(), a.getString(attr), textStyle);
setTypeface(typeface);
}
}
TypedValue bg = new TypedValue();
a.getValue(R.styleable.Button_android_background, bg);
if (bg.type >= TypedValue.TYPE_FIRST_COLOR_INT && bg.type <= TypedValue.TYPE_LAST_COLOR_INT && bg.data == 0)
setBackgroundDrawable(new ColorStateListDrawable(AnimatedColorStateList.fromList(new DefaultPrimaryColorStateList(getContext()), animation -> postInvalidate())));
Carbon.initRippleDrawable(this, a, rippleIds);
Carbon.initElevation(this, a, elevationIds);
Carbon.initTint(this, a, tintIds);
Carbon.initAnimations(this, a, animationIds);
Carbon.initTouchMargin(this, a, touchMarginIds);
Carbon.initHtmlText(this, a, R.styleable.Button_carbon_htmlText);
Carbon.initStroke(this, a, strokeIds);
setCornerRadius(a.getDimension(R.styleable.Button_carbon_cornerRadius, 0));
a.recycle();
}
Aggregations