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;
}
}
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;
}
}
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;
}
}
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;
}
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();
}
}
Aggregations