use of android.support.v7.widget.TintTypedArray in project material-components-android by material-components.
the class CollapsingTextHelper method setCollapsedTextAppearance.
void setCollapsedTextAppearance(int resId) {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, android.support.v7.appcompat.R.styleable.TextAppearance);
if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor)) {
mCollapsedTextColor = a.getColorStateList(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor);
}
if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize)) {
mCollapsedTextSize = a.getDimensionPixelSize(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, (int) mCollapsedTextSize);
}
mCollapsedShadowColor = a.getInt(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowColor, 0);
mCollapsedShadowDx = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDx, 0);
mCollapsedShadowDy = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDy, 0);
mCollapsedShadowRadius = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowRadius, 0);
a.recycle();
if (Build.VERSION.SDK_INT >= 16) {
mCollapsedTypeface = readFontFamilyTypeface(resId);
}
recalculate();
}
use of android.support.v7.widget.TintTypedArray in project material-components-android by material-components.
the class CollapsingTextHelper method setExpandedTextAppearance.
void setExpandedTextAppearance(int resId) {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(mView.getContext(), resId, android.support.v7.appcompat.R.styleable.TextAppearance);
if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor)) {
mExpandedTextColor = a.getColorStateList(android.support.v7.appcompat.R.styleable.TextAppearance_android_textColor);
}
if (a.hasValue(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize)) {
mExpandedTextSize = a.getDimensionPixelSize(android.support.v7.appcompat.R.styleable.TextAppearance_android_textSize, (int) mExpandedTextSize);
}
mExpandedShadowColor = a.getInt(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowColor, 0);
mExpandedShadowDx = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDx, 0);
mExpandedShadowDy = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowDy, 0);
mExpandedShadowRadius = a.getFloat(android.support.v7.appcompat.R.styleable.TextAppearance_android_shadowRadius, 0);
a.recycle();
if (Build.VERSION.SDK_INT >= 16) {
mExpandedTypeface = readFontFamilyTypeface(resId);
}
recalculate();
}
use of android.support.v7.widget.TintTypedArray in project Douya by DreaminginCodeZH.
the class FriendlySwitchCompat method setSwitchTextAppearance.
/**
* Sets the switch text color, size, style, hint color, and highlight color
* from the specified TextAppearance resource.
*
* @attr ref android.support.v7.appcompat.R.styleable#SwitchCompat_switchTextAppearance
*/
public void setSwitchTextAppearance(Context context, int resid) {
TintTypedArray appearance = TintTypedArray.obtainStyledAttributes(context, resid, R.styleable.TextAppearance);
ColorStateList colors;
int ts;
colors = appearance.getColorStateList(R.styleable.TextAppearance_android_textColor);
if (colors != null) {
mTextColors = colors;
} else {
// If no color set in TextAppearance, default to the view's textColor
mTextColors = getTextColors();
}
ts = appearance.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
if (ts != 0) {
if (ts != mTextPaint.getTextSize()) {
mTextPaint.setTextSize(ts);
requestLayout();
}
}
int typefaceIndex, styleIndex;
typefaceIndex = appearance.getInt(R.styleable.TextAppearance_android_typeface, -1);
styleIndex = appearance.getInt(R.styleable.TextAppearance_android_textStyle, -1);
setSwitchTypefaceByIndex(typefaceIndex, styleIndex);
boolean allCaps = appearance.getBoolean(R.styleable.TextAppearance_textAllCaps, false);
if (allCaps) {
mSwitchTransformationMethod = new AllCapsTransformationMethod(getContext());
} else {
mSwitchTransformationMethod = null;
}
appearance.recycle();
}
use of android.support.v7.widget.TintTypedArray in project MaterialProgressBar by DreaminginCodeZH.
the class MaterialProgressBar method init.
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
Context context = getContext();
TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.MaterialProgressBar, defStyleAttr, defStyleRes);
mProgressStyle = a.getInt(R.styleable.MaterialProgressBar_mpb_progressStyle, PROGRESS_STYLE_CIRCULAR);
boolean setBothDrawables = a.getBoolean(R.styleable.MaterialProgressBar_mpb_setBothDrawables, false);
boolean useIntrinsicPadding = a.getBoolean(R.styleable.MaterialProgressBar_mpb_useIntrinsicPadding, true);
boolean showProgressBackground = a.getBoolean(R.styleable.MaterialProgressBar_mpb_showProgressBackground, mProgressStyle == PROGRESS_STYLE_HORIZONTAL);
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressTint)) {
mProgressTintInfo.mProgressTint = a.getColorStateList(R.styleable.MaterialProgressBar_mpb_progressTint);
mProgressTintInfo.mHasProgressTint = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressTintMode)) {
mProgressTintInfo.mProgressTintMode = DrawableCompat.parseTintMode(a.getInt(R.styleable.MaterialProgressBar_mpb_progressTintMode, -1), null);
mProgressTintInfo.mHasProgressTintMode = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_secondaryProgressTint)) {
mProgressTintInfo.mSecondaryProgressTint = a.getColorStateList(R.styleable.MaterialProgressBar_mpb_secondaryProgressTint);
mProgressTintInfo.mHasSecondaryProgressTint = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_secondaryProgressTintMode)) {
mProgressTintInfo.mSecondaryProgressTintMode = DrawableCompat.parseTintMode(a.getInt(R.styleable.MaterialProgressBar_mpb_secondaryProgressTintMode, -1), null);
mProgressTintInfo.mHasSecondaryProgressTintMode = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressBackgroundTint)) {
mProgressTintInfo.mProgressBackgroundTint = a.getColorStateList(R.styleable.MaterialProgressBar_mpb_progressBackgroundTint);
mProgressTintInfo.mHasProgressBackgroundTint = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_progressBackgroundTintMode)) {
mProgressTintInfo.mProgressBackgroundTintMode = DrawableCompat.parseTintMode(a.getInt(R.styleable.MaterialProgressBar_mpb_progressBackgroundTintMode, -1), null);
mProgressTintInfo.mHasProgressBackgroundTintMode = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_indeterminateTint)) {
mProgressTintInfo.mIndeterminateTint = a.getColorStateList(R.styleable.MaterialProgressBar_mpb_indeterminateTint);
mProgressTintInfo.mHasIndeterminateTint = true;
}
if (a.hasValue(R.styleable.MaterialProgressBar_mpb_indeterminateTintMode)) {
mProgressTintInfo.mIndeterminateTintMode = DrawableCompat.parseTintMode(a.getInt(R.styleable.MaterialProgressBar_mpb_indeterminateTintMode, -1), null);
mProgressTintInfo.mHasIndeterminateTintMode = true;
}
a.recycle();
switch(mProgressStyle) {
case PROGRESS_STYLE_CIRCULAR:
if (!isIndeterminate() || setBothDrawables) {
throw new UnsupportedOperationException("Determinate circular drawable is not yet supported");
} else {
if (!isInEditMode()) {
setIndeterminateDrawable(new IndeterminateProgressDrawable(context));
}
}
break;
case PROGRESS_STYLE_HORIZONTAL:
if (isIndeterminate() || setBothDrawables) {
if (!isInEditMode()) {
setIndeterminateDrawable(new IndeterminateHorizontalProgressDrawable(context));
}
}
if (!isIndeterminate() || setBothDrawables) {
setProgressDrawable(new HorizontalProgressDrawable(context));
}
break;
default:
throw new IllegalArgumentException("Unknown progress style: " + mProgressStyle);
}
setUseIntrinsicPadding(useIntrinsicPadding);
setShowProgressBackground(showProgressBackground);
}
use of android.support.v7.widget.TintTypedArray in project Douya by DreaminginCodeZH.
the class FriendlyCardView method init.
private void init(AttributeSet attrs, int defStyleAttr) {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, R.styleable.CardView, defStyleAttr, R.style.CardView_Light);
setMaxCardElevation(a.getDimension(R.styleable.CardView_cardMaxElevation, getCardElevation()));
a.recycle();
setUseCompatPadding(true);
setPreventCornerOverlap(false);
// User should never click through a card.
setClickable(true);
}
Aggregations