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