Search in sources :

Example 36 with ColorStateList

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);
        }
    }
}
Also used : PorterDuff(android.graphics.PorterDuff) ColorStateList(android.content.res.ColorStateList)

Example 37 with ColorStateList

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);
}
Also used : ColorStateList(android.content.res.ColorStateList)

Example 38 with ColorStateList

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);
}
Also used : ColorStateList(android.content.res.ColorStateList)

Example 39 with ColorStateList

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));
    }
}
Also used : ColorStateList(android.content.res.ColorStateList) AnimatedView(carbon.animation.AnimatedView) StateAnimatorView(carbon.widget.StateAnimatorView) StrokeView(carbon.widget.StrokeView) View(android.view.View) InsetView(carbon.widget.InsetView) RippleView(carbon.drawable.ripple.RippleView) TouchMarginView(carbon.widget.TouchMarginView) TintedView(carbon.widget.TintedView) MaxSizeView(carbon.widget.MaxSizeView) ShadowView(carbon.shadow.ShadowView) RippleDrawable(carbon.drawable.ripple.RippleDrawable)

Example 40 with ColorStateList

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;
}
Also used : ColorStateList(android.content.res.ColorStateList) TintedView(carbon.widget.TintedView)

Aggregations

ColorStateList (android.content.res.ColorStateList)280 Paint (android.graphics.Paint)90 TypedArray (android.content.res.TypedArray)76 Drawable (android.graphics.drawable.Drawable)48 TextPaint (android.text.TextPaint)42 Resources (android.content.res.Resources)25 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)22 TypedValue (android.util.TypedValue)21 TextView (android.widget.TextView)19 Context (android.content.Context)18 SuppressLint (android.annotation.SuppressLint)17 SmallTest (android.test.suitebuilder.annotation.SmallTest)13 AllCapsTransformationMethod (android.text.method.AllCapsTransformationMethod)13 RippleDrawable (android.graphics.drawable.RippleDrawable)12 StateListDrawable (android.graphics.drawable.StateListDrawable)12 View (android.view.View)12 Nullable (android.annotation.Nullable)10 Bitmap (android.graphics.Bitmap)10 TextAppearanceSpan (android.text.style.TextAppearanceSpan)9 PorterDuff (android.graphics.PorterDuff)8