Search in sources :

Example 86 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project superCleanMaster by joyoyao.

the class RoundCornerProgressBar method setProgressColor.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public void setProgressColor(int color) {
    progressColor = color;
    int radius = this.radius - padding / 2;
    GradientDrawable gradient = new GradientDrawable();
    gradient.setShape(GradientDrawable.RECTANGLE);
    gradient.setColor(progressColor);
    gradient.setCornerRadii(new float[] { radius, radius, radius, radius, radius, radius, radius, radius });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        layoutProgress.setBackground(gradient);
    } else {
        layoutProgress.setBackgroundDrawable(gradient);
    }
    if (!isProgressBarCreated) {
        isProgressColorSetBeforeDraw = true;
    }
}
Also used : SuppressLint(android.annotation.SuppressLint) GradientDrawable(android.graphics.drawable.GradientDrawable) SuppressLint(android.annotation.SuppressLint)

Example 87 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project superCleanMaster by joyoyao.

the class TextRoundCornerProgressBar method setBackgroundColor.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public void setBackgroundColor(int color) {
    backgroundColor = color;
    GradientDrawable gradient = new GradientDrawable();
    gradient.setShape(GradientDrawable.RECTANGLE);
    gradient.setColor(backgroundColor);
    gradient.setCornerRadius(radius);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        layoutBackground.setBackgroundDrawable(gradient);
    } else {
        layoutBackground.setBackground(gradient);
    }
    if (!isProgressBarCreated) {
        isBackgroundColorSetBeforeDraw = true;
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable) SuppressLint(android.annotation.SuppressLint)

Example 88 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project superCleanMaster by joyoyao.

the class IconRoundCornerProgressBar method setProgressColor.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public void setProgressColor(int color) {
    progressColor = color;
    int radius = this.radius - (padding / 2);
    GradientDrawable gradient = new GradientDrawable();
    gradient.setShape(GradientDrawable.RECTANGLE);
    gradient.setColor(progressColor);
    gradient.setCornerRadii(new float[] { 0, 0, radius, radius, radius, radius, 0, 0 });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        layoutProgress.setBackgroundDrawable(gradient);
    } else {
        layoutProgress.setBackground(gradient);
    }
    if (!isProgressBarCreated) {
        isProgressColorSetBeforeDraw = true;
    }
}
Also used : SuppressLint(android.annotation.SuppressLint) GradientDrawable(android.graphics.drawable.GradientDrawable) SuppressLint(android.annotation.SuppressLint)

Example 89 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project superCleanMaster by joyoyao.

the class IconRoundCornerProgressBar method setBackgroundColor.

@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public void setBackgroundColor(int color) {
    backgroundColor = color;
    GradientDrawable gradient = new GradientDrawable();
    gradient.setShape(GradientDrawable.RECTANGLE);
    gradient.setColor(backgroundColor);
    gradient.setCornerRadius(radius);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        layoutBackground.setBackgroundDrawable(gradient);
    } else {
        layoutBackground.setBackground(gradient);
    }
    if (!isProgressBarCreated) {
        isBackgroundColorSetBeforeDraw = true;
    }
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable) SuppressLint(android.annotation.SuppressLint)

Example 90 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project FlatUI by eluleci.

the class FlatEditText method init.

private void init(AttributeSet attrs) {
    if (attributes == null)
        attributes = new Attributes(this, getResources());
    if (attrs != null) {
        // getting android default tags for textColor and textColorHint
        hasOwnTextColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColor") != null;
        hasOwnHintColor = attrs.getAttributeValue(FlatUI.androidStyleNameSpace, "textColorHint") != null;
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatEditText);
        // getting common attributes
        int customTheme = a.getResourceId(R.styleable.fl_FlatEditText_fl_theme, Attributes.DEFAULT_THEME);
        attributes.setThemeSilent(customTheme, getResources());
        attributes.setFontFamily(a.getString(R.styleable.fl_FlatEditText_fl_fontFamily));
        attributes.setFontWeight(a.getString(R.styleable.fl_FlatEditText_fl_fontWeight));
        attributes.setFontExtension(a.getString(R.styleable.fl_FlatEditText_fl_fontExtension));
        attributes.setTextAppearance(a.getInt(R.styleable.fl_FlatEditText_fl_textAppearance, Attributes.DEFAULT_TEXT_APPEARANCE));
        attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatEditText_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));
        attributes.setBorderWidth(a.getDimensionPixelSize(R.styleable.fl_FlatEditText_fl_borderWidth, Attributes.DEFAULT_BORDER_WIDTH_PX));
        // getting view specific attributes
        style = a.getInt(R.styleable.fl_FlatEditText_fl_fieldStyle, 0);
        a.recycle();
    }
    GradientDrawable backgroundDrawable = new GradientDrawable();
    backgroundDrawable.setCornerRadius(attributes.getRadius());
    if (style == 0) {
        // flat
        if (!hasOwnTextColor)
            setTextColor(attributes.getColor(3));
        backgroundDrawable.setColor(attributes.getColor(2));
        backgroundDrawable.setStroke(0, attributes.getColor(2));
    } else if (style == 1) {
        // box
        if (!hasOwnTextColor)
            setTextColor(attributes.getColor(2));
        backgroundDrawable.setColor(Color.WHITE);
        backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
    } else if (style == 2) {
        // transparent
        if (!hasOwnTextColor)
            setTextColor(attributes.getColor(1));
        backgroundDrawable.setColor(Color.TRANSPARENT);
        backgroundDrawable.setStroke(attributes.getBorderWidth(), attributes.getColor(2));
    }
    setBackgroundDrawable(backgroundDrawable);
    if (!hasOwnHintColor)
        setHintTextColor(attributes.getColor(3));
    if (attributes.getTextAppearance() == 1)
        setTextColor(attributes.getColor(0));
    else if (attributes.getTextAppearance() == 2)
        setTextColor(attributes.getColor(3));
    // check for IDE preview render
    if (!this.isInEditMode()) {
        Typeface typeface = FlatUI.getFont(getContext(), attributes);
        if (typeface != null)
            setTypeface(typeface);
    }
}
Also used : Typeface(android.graphics.Typeface) TypedArray(android.content.res.TypedArray) Attributes(com.cengalabs.flatui.Attributes) GradientDrawable(android.graphics.drawable.GradientDrawable)

Aggregations

GradientDrawable (android.graphics.drawable.GradientDrawable)169 Paint (android.graphics.Paint)19 Drawable (android.graphics.drawable.Drawable)19 StateListDrawable (android.graphics.drawable.StateListDrawable)19 View (android.view.View)19 SuppressLint (android.annotation.SuppressLint)18 TextView (android.widget.TextView)18 LayerDrawable (android.graphics.drawable.LayerDrawable)16 ImageView (android.widget.ImageView)14 LinearLayout (android.widget.LinearLayout)12 TypedArray (android.content.res.TypedArray)8 FrameLayout (android.widget.FrameLayout)6 TimeAnimator (android.animation.TimeAnimator)5 Typeface (android.graphics.Typeface)5 LayoutInflater (android.view.LayoutInflater)5 ViewGroup (android.view.ViewGroup)5 Attributes (com.cengalabs.flatui.Attributes)5 Resources (android.content.res.Resources)4 TextPaint (android.text.TextPaint)4 Button (android.widget.Button)4