Search in sources :

Example 31 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project UltimateAndroid by cymcsg.

the class TextRoundCornerProgressBar 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 32 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project UltimateAndroid by cymcsg.

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 33 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project UltimateAndroid by cymcsg.

the class IconRoundCornerProgressBar method setHeaderColor.

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

Example 34 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project UltimateAndroid by cymcsg.

the class Configuration method getDrawableFromColor.

/**
	 * usd for get drawable from color
	 * 
	 * @param color
	 * @return
	 */
private Drawable getDrawableFromColor(int color) {
    GradientDrawable tempDrawable = new GradientDrawable();
    tempDrawable.setCornerRadius(this.getRadius());
    tempDrawable.setColor(color);
    return tempDrawable;
}
Also used : GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 35 with GradientDrawable

use of android.graphics.drawable.GradientDrawable in project FlexibleAdapter by davideas.

the class FastScroller method setBubbleAndHandleColor.

private void setBubbleAndHandleColor(int accentColor) {
    //TODO: Programmatically generate the Drawables instead of using resources
    //BubbleDrawable accentColor
    GradientDrawable bubbleDrawable;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        bubbleDrawable = (GradientDrawable) getResources().getDrawable(R.drawable.fast_scroller_bubble, null);
    } else {
        //noinspection deprecation
        bubbleDrawable = (GradientDrawable) getResources().getDrawable(R.drawable.fast_scroller_bubble);
    }
    assert bubbleDrawable != null;
    bubbleDrawable.setColor(accentColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        bubble.setBackground(bubbleDrawable);
    } else {
        //noinspection deprecation
        bubble.setBackgroundDrawable(bubbleDrawable);
    }
    //HandleDrawable accentColor
    try {
        StateListDrawable stateListDrawable;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            stateListDrawable = (StateListDrawable) getResources().getDrawable(R.drawable.fast_scroller_handle, null);
        } else {
            //noinspection deprecation
            stateListDrawable = (StateListDrawable) getResources().getDrawable(R.drawable.fast_scroller_handle);
        }
        //Method is still hidden, invoke Java reflection
        Method getStateDrawable = StateListDrawable.class.getMethod("getStateDrawable", int.class);
        GradientDrawable handleDrawable = (GradientDrawable) getStateDrawable.invoke(stateListDrawable, 0);
        handleDrawable.setColor(accentColor);
        handle.setImageDrawable(stateListDrawable);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Method(java.lang.reflect.Method) StateListDrawable(android.graphics.drawable.StateListDrawable) 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