use of android.content.res.ColorStateList in project material-dialogs by afollestad.
the class MDTintHelper method setTint.
private static void setTint(@NonNull ProgressBar progressBar, @ColorInt int color, boolean skipIndeterminate) {
ColorStateList sl = ColorStateList.valueOf(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
progressBar.setProgressTintList(sl);
progressBar.setSecondaryProgressTintList(sl);
if (!skipIndeterminate) {
progressBar.setIndeterminateTintList(sl);
}
} else {
PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
mode = PorterDuff.Mode.MULTIPLY;
}
if (!skipIndeterminate && progressBar.getIndeterminateDrawable() != null) {
progressBar.getIndeterminateDrawable().setColorFilter(color, mode);
}
if (progressBar.getProgressDrawable() != null) {
progressBar.getProgressDrawable().setColorFilter(color, mode);
}
}
}
use of android.content.res.ColorStateList in project material-dialogs by afollestad.
the class MDTintHelper method setTint.
public static void setTint(@NonNull RadioButton radioButton, @ColorInt int color) {
final int disabledColor = DialogUtils.getDisabledColor(radioButton.getContext());
ColorStateList sl = new ColorStateList(new int[][] { new int[] { android.R.attr.state_enabled, -android.R.attr.state_checked }, new int[] { android.R.attr.state_enabled, android.R.attr.state_checked }, new int[] { -android.R.attr.state_enabled, -android.R.attr.state_checked }, new int[] { -android.R.attr.state_enabled, android.R.attr.state_checked } }, new int[] { DialogUtils.resolveColor(radioButton.getContext(), R.attr.colorControlNormal), color, disabledColor, disabledColor });
setTint(radioButton, sl);
}
use of android.content.res.ColorStateList in project uCrop by Yalantis.
the class AspectRatioTextView method applyActiveColor.
private void applyActiveColor(@ColorInt int activeColor) {
if (mDotPaint != null) {
mDotPaint.setColor(activeColor);
}
ColorStateList textViewColorStateList = new ColorStateList(new int[][] { new int[] { android.R.attr.state_selected }, new int[] { 0 } }, new int[] { activeColor, ContextCompat.getColor(getContext(), R.color.ucrop_color_widget) });
setTextColor(textViewColorStateList);
}
use of android.content.res.ColorStateList in project Carbon by ZieIony.
the class Carbon method initRippleDrawable.
public static void initRippleDrawable(RippleView rippleView, TypedArray a, int[] ids) {
int carbon_rippleColor = ids[0];
int carbon_rippleStyle = ids[1];
int carbon_rippleHotspot = ids[2];
int carbon_rippleRadius = ids[3];
View view = (View) rippleView;
if (view.isInEditMode())
return;
ColorStateList color = a.getColorStateList(carbon_rippleColor);
if (color != null) {
RippleDrawable.Style style = RippleDrawable.Style.values()[a.getInt(carbon_rippleStyle, RippleDrawable.Style.Background.ordinal())];
boolean useHotspot = a.getBoolean(carbon_rippleHotspot, true);
int radius = (int) a.getDimension(carbon_rippleRadius, -1);
rippleView.setRippleDrawable(createRippleDrawable(color, style, view, useHotspot, radius));
}
}
use of android.content.res.ColorStateList in project Carbon by ZieIony.
the class Carbon method getBackgroundTintAlpha.
public static float getBackgroundTintAlpha(View child) {
if (!(child instanceof TintedView))
return 255;
ColorStateList tint = ((TintedView) child).getBackgroundTint();
if (tint == null)
return 255;
int color = tint.getColorForState(child.getDrawableState(), tint.getDefaultColor());
return (color >> 24) & 0xff;
}
Aggregations