use of android.graphics.drawable.GradientDrawable in project StyleableToast by Muddz.
the class StyleableToast method getShape.
// ____________________ PUBLIC METHODS ENDS ________________________
private GradientDrawable getShape() {
getShapeAttributes();
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setCornerRadius(getTypedValueInDP(context, cornerRadius));
gradientDrawable.setStroke((int) getTypedValueInDP(context, strokeWidth), strokeColor);
gradientDrawable.setColor(backgroundColor);
gradientDrawable.setAlpha(alpha);
return gradientDrawable;
}
use of android.graphics.drawable.GradientDrawable in project pictureapp by EyeSeeTea.
the class BaseLayoutUtils method highlightSelection.
/**
* @param view
* @param option
*/
public static void highlightSelection(View view, Option option) {
Drawable selectedBackground = view.getContext().getResources().getDrawable(R.drawable.background_dynamic_clicked_option);
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
//JELLY_BEAN=API16
view.setBackground(selectedBackground);
} else {
view.setBackgroundDrawable(selectedBackground);
}
if (option != null) {
GradientDrawable bgShape = (GradientDrawable) view.getBackground();
String backGColor = option.getOptionAttribute() != null ? option.getOptionAttribute().getBackground_colour() : option.getBackground_colour();
bgShape.setColor(Color.parseColor("#" + backGColor));
bgShape.setStroke(3, Color.WHITE);
}
//the view is a framelayout with a imageview, or a imageview, or a custombutton
ImageView imageView = null;
if (view instanceof FrameLayout) {
FrameLayout f = (FrameLayout) view;
imageView = (ImageView) f.getChildAt(0);
} else if (view instanceof ImageView) {
imageView = (ImageView) view;
}
if (imageView != null) {
imageView.clearColorFilter();
}
}
use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.
the class PhoneConfirmationButton method setState.
public void setState(State state) {
this.state = state;
switch(state) {
case NONE:
setBackground(null);
setText("");
setClickable(false);
setVisibility(View.GONE);
break;
case INVALID:
setBackground(null);
setText("");
setClickable(false);
setVisibility(View.VISIBLE);
break;
case CONFIRM:
setClickable(true);
GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TL_BR, new int[] { accentColor, accentColor, accentColor });
gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
gradientDrawable.setCornerRadii(new float[] { 0, 0, cornerRadius, cornerRadius, cornerRadius, cornerRadius, 0, 0 });
setBackground(gradientDrawable);
setText(nextGlyph);
setVisibility(View.VISIBLE);
break;
}
invalidate();
}
use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.
the class OnBoardingHintFragment method onAccentColorHasChanged.
//////////////////////////////////////////////////////////////////////////////////////////
//
// AccentColorObserver
//
//////////////////////////////////////////////////////////////////////////////////////////
@Override
public void onAccentColorHasChanged(Object sender, int color) {
if (hintContainer == null) {
return;
}
GradientDrawable circleDrawable = (GradientDrawable) hintContainer.getBackground();
circleDrawable.setColor(color);
}
use of android.graphics.drawable.GradientDrawable in project wire-android by wireapp.
the class ConfirmationMenu method getButtonBackground.
private Drawable getButtonBackground(int borderColor, int fillColor, int strokeWidth, int cornerRadius) {
int fillColorPressed = getPressColor(PRESSED_ALPHA, fillColor);
int borderColorPressed = getPressColor(PRESSED_ALPHA, borderColor);
GradientDrawable gradientDrawablePressed = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColorPressed, fillColorPressed });
gradientDrawablePressed.setStroke(strokeWidth, borderColorPressed);
gradientDrawablePressed.setCornerRadius(cornerRadius);
GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { fillColor, fillColor });
gradientDrawable.setStroke(strokeWidth, borderColor);
gradientDrawable.setCornerRadius(cornerRadius);
StateListDrawable states = new StateListDrawable();
states.addState(new int[] { android.R.attr.state_pressed }, gradientDrawablePressed);
states.addState(new int[] { android.R.attr.state_focused }, gradientDrawablePressed);
states.addState(new int[] {}, gradientDrawable);
return states;
}
Aggregations